Rewrite for dependency injection and TDD support.