Refactored MainWindow code, spliting it into more specific files.