Code refactoring - clean up main window file