Additional code cleanup:
Refactor resize calculation to a single place (instead of 2)
Get rid of some helper functions, move others into narrower scope
Remove attributes that duplicate information