Some cleanup and a refactoring of the WindowManager class