Structured MainWindow code