Refactoring and increased test coverage.