Refactored setupwindow a bit