Fixed various bugs related to screen rotation