Fixed bug which crashed the application after the orientation was changed.