Added saving state after rotation and fixed few bugs