Cleaned up the window implementation a little bit