Major rewrite, new window management