Fix rotation performance issue and some minor changes