Congruence modules and the Wiles-Lenstra-Diamond numerical criterion in higher codimensions