Fixed flickering when resizing the window