Implement dynamic di

This is an initial implementation of DI.