More work on resizing and a bit of refactoring.