Improved handling for the resizing of windows