Refactor'd for full DI compatibility