Fixed bug that caused crash when rotating orientation.