anchor.diff:              Acc;
           ({Node0, Count}, Acc) ->
               Node = list_to_existing_atom(binary_to_list(Node0)),
  -            % Compute the max number of shards to donate.
  -            DC0 = erlang:min(Count - TargetLevel, Limit - length(Acc)),
  -            InternalAcc0 = {Node, TargetNodes0, Acc, DC0},
  +            InternalAcc0 = #gacc{
  +                node = Node,
  +                targets = TargetNodes0,
  +                moves = Acc,
  +                limit = erlang:min(Count - TargetLevel, Limit - length(Acc)),
  +                target_level = TargetLevel
  +            },
               try mem3_shards:fold(fun donate_fold/2, InternalAcc0) of
  -                {_, _, Moves, _} ->
  +                #gacc{moves = Moves} ->
                       Moves
               catch
                   {complete, Moves} ->
  
positive.code: ]).
  
  -include("mem3.hrl").
  
  %% @equiv expand(1000)
  -spec expand() -> [{atom(), #shard{}, node()}].
  
negative.code:     end, SortedByCount),
      case {lists:member(Shard, Shards), Candidates} of
          {false, _} ->
              Acc0;
          {true, []} ->
              Acc0;
          {true, [{Node, _} | _]} ->
              Acc0;
          {true, [{Target, _} | _]} ->
              % Execute the move only if the target has fewer shards for this DB
              % than the source. Otherwise we'd generate a local imbalance.
              SourceCount = get_shard_count(Node, SortedByCount),
              TargetCount = get_shard_count(Target, SortedByCount),
              % Execute the move only if the target needs shards.
              NodeKey = couch_util:to_binary(Target),
              Total = couch_util:get_value(NodeKey, shard_count_by_node(Moves)),
              if (TargetCount < SourceCount), (Total < TargetLevel) ->
                  print({move, Shard, Target}),
                  Acc0#gacc{
                      moves = [{move, Shard, Target} | Moves],
                      limit = DC - 1
                  };
              true ->
                  Acc0
              end
      end;
  donate_fold(_Shard, Acc) ->
  