Bug fixes and tweaks.

Specifically fixing #20.