Fixed small window bug and changed to using global window list var

After seeing Jeroens fix i noticed there was another part that suffered the same mistake. 

I've also switched to using a global variable for window_list so that we can one day switch it for the definition of the window list array.