Fix window resizing bug