Set repair

This was originally just to repair broken sets, but when I realized that the code already had some half-assed attempts to make it so that content rules (at least some of them) control type, I decided to make a more general patch.