Cleanup dependencies, declaring  undeclared ones and removing unused ones.