Before removing a mutation, remove its dependencies

Fixes #1509