using hash codes to speed up equals() when possible