Fix too aggressive cleanup of dependencies.