Correct hashCode implementation.

Follow the contract of hashCode and equals interaction