Maintain constraint index constraintsByName

In two key places, `constraintsByName` is not kept up to date, which can lead to serious problems.