Fix a bug in depenency invalidation