refactor & cleanup mainwindow