Added Window and support for it.

Fixed some bugs.