Fixed bugs with orientation change.