Fixed a bug that crashed the app on orientation change.