Small refactorings to remove some code smells.

For issue #231.