Improved the window size change handling