Updated equality check to deal with value types.