Fixed a bug that messed up window size after orientation change or window resize.