Refactoring for style and testability.