Cleaning up windowing code

Merging the two files into one.