Small cleanup and refactoring.

Also fixes #3.