Cleanup

Major polish and type checker pass.

Fixes #10.