this fixes the obvious problems but there are still some rotation jumping when clamping in some cases.