Correctly handle resizing the browser window