now remembers resizing
cleaned up code