Dynamic Flash resizing

Fixes #270.
Fixes #354.