Fixed bug in window update code