Automatic resizing.

Fixes #111. It's a costly operation, but it's working.