Implement dynamic di

This is an initial implementation of DI.

Please review only the second commit. The first commit will be gone once #45 is merged.

After seeing how it is used,  I think I like this better. But still would love to hear your reasoning.