Dependency injection

First draft, you may want some things re-wording so just give me a shout.