Refactor. Fixes #6