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.