refactor window-handling wip