Fix so that resize does fit to window

Closes #630