improved resizing of window.