Cleaning up the code. Also fixed the screen rotation on first use.