Fixed some memory leaks in Window.cpp