Fix flickering when resizing