Added dependency injection back into the environment config - not sure this is the best way, must revise.