Refactor dependency injection to be more sensible, explicit, and less tightly coupled