Major cleanup in MainWindow