Remove redundant equals() and hashCode() in the constraints.

This exhibited some bugs in the implementation and two small in the json serialisation.
Simplify some code.