fix some issues on resizing the window