Refactored to remove some injected dependencies.