Improved resizing of main window