Dependency refactoring

Before I even got to add the knife-solo support, here is some refactoring for dependency handling. I might not have understod everything, so take a critic look. =)