Refactoring MainWindow (more sub-methods for a more easy to read code).