handles resizing correctly. fixes #28