Code cleanup of window resize