Refactor. Improve window resizing.