Large overhaul for dependency injection