Fix indentation. Fix minor bug. Refactor a bit for readability.

Fixes #141.