Added dependencies, some refactoring