Clean up duplicated resize code.

Fixes #12