Fix equals, compareTo and hashCode to be canonical in implementation.