Refactoring dependency tool.

Now that the concept worked, I've refactored the code in classes and
using a predictable flow.