Fixed two bugs causing the app to crash when turning to landscape