refactor main window layout and fix sidescrolling bug