Added dependencies, refactored a bit