Move id, equals and hashCode to common superclass