Corrected computing of rotation, removed redundant code