Closes #69 and contains a bit of cleanup/refactor.