Fix equals, hashCode and serialization.