General cleanup pass and bugfix.

Fixes #2.