Fixed bug in window resizing