Refactoring to use container

This PR will introduce dependency injection, fixing #35.and tidying up the mess of helpers.