Refactoring.

Just added a couple of helpers, moved import statements, replaced instance vars
with `let` statements.