Refactored MainWindow class