Fixed a bug which caused the application to crash when the screen
orientation was changed.