Some minor refactoring and cleaning up (#112).