Refactor and rewrite dependency injection container.