Refactored creation of main window.