Implement minimal rewrite.

Closes #8.