Main window refactoring

Fixes #2 #10