Bugfix & cleanup.

Fixes issue #37.