Fix for issues #3931 and #3932

Created a new branch to clean up previous pull request. 
Ok no worries, I'll mention in the docs that implementing equals along with hashCode is best