split main window code into different modules.