Fixed a crash on orientation change.