Fixed bug that occurred during window resize.