Refactored main window.