Fixes bugs associated with orientation change.