anchor.diff:       #sampler{capacity = Capacity2} = Sampler2) when Capacity2 > Capacity1 ->
       join(Sampler2, Sampler1);
   join(Sampler1, #sampler{tree = Tree2}) ->
  -    lists:foldl(fun add_hash/2, Sampler1, gb_trees:to_list(Tree2)).
  +    lists:foldl(fun({_Hash, {_V,_A}}=Data, Sampler) ->
  +                        add_hash(Data, Sampler);
  +                   ({Hash, Bucket}, Sampler) when is_list(Bucket) ->
  +                        lists:foldl(fun(VA, Acc) ->
  +                                            add_hash({Hash, VA}, Acc)
  +                                    end, Sampler, Bucket)
  +                end, Sampler1, gb_trees:to_list(Tree2)).
   
   %% Return a list of {V, PV}
   get_samples(undefined) -> [];
  
positive.code: %% hash function (erlang:phash2 with the Range set to 2^32 is recommended).
  %% In case of doubt, just use add/2 above.
  add_hash(_Data, undefined) -> undefined;
  add_hash({Hash, VA}, #sampler{capacity = Capacity,
                                size = Size0, tree=Tree0,
                                max_hash = MaxHash0} = Sampler)
    when Size0 < Capacity ->
      {Tree, Size} = update_tree(Hash, VA, Tree0, Size0),
      MaxHash = max(Hash, MaxHash0),
      Sampler#sampler{size = Size, max_hash = MaxHash, tree = Tree};
  add_hash({Hash, _VA}, #sampler{max_hash = MaxHash} = Sampler)
    when Hash > MaxHash ->
      Sampler;
  add_hash({Hash, {V, A}}, #sampler{max_hash = MaxHash,
  
negative.code:     PV = ds_pvattrs:add(A, PV0),
      Tree = gb_trees:update(Hash, {V, PV}, Tree0),
      Sampler#sampler{tree = Tree};
  add_hash({Hash, {V, A}}, #sampler{capacity = Capacity,
                                    size = Size0, tree = Tree0} = Sampler) ->
      {Tree1, Size1} = update_tree(Hash, {V, A}, Tree0, Size0),
      if Size1 > Capacity ->
              {_, Value, Tree} = gb_trees:take_largest(Tree1),
              Size = case Value of
                         {_Vmax,_PV} -> Size1 - 1;
                         Bucket -> Size1 - length(Bucket)
                     end,
              {MaxHash, _} = gb_trees:largest(Tree),
  