improve rotation handling

this commit was rewritten/inspired by one made to our jb 4.1 branch by sonicxml.

cheers buddy!

Change-Id: Ib3b46aa54e7bf6602f8c0557ed770624063af529