improved and normalized dependency injection and some refactoring