Cleaned up and revised MainWindow logic