Fixed bugs in saveOrientation