Code tidying in mainwindow