more window behavior fixing
Small refactoring