anchor.diff:  % Merkle Tree specific
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
  --spec check_node([merkle_cmp_request()], merkle_tree:merkle_tree() | RestTree) 
  -        -> {[merkle_cmp_result()], RestTree}
  -    when is_subtype(RestTree, [merkle_tree:mt_node()]).
  +-spec check_node([merkle_cmp_request()], merkle_tree:merkle_tree() | NodeList) 
  +        -> {[merkle_cmp_result()], RestTree::NodeList, ResolveReq::NodeList}
  +    when is_subtype(NodeList, [merkle_tree:mt_node()]).
   check_node(L, Tree) ->
       case merkle_tree:is_merkle_tree(Tree) of
  -        false -> p_check_node(L, Tree, [], []);
  -        true -> p_check_node(L, [merkle_tree:get_root(Tree)], [], [])
  +        false -> p_check_node(L, Tree, [], [], []);
  +        true -> p_check_node(L, [merkle_tree:get_root(Tree)], [], [], [])
       end.
   
   %% @doc Compares the given Hashes from the other node with my merkle_tree nodes.
   %%      Returns the comparison results and the rest nodes to check in a next
   %%      step.
  --spec p_check_node(Hashes::[merkle_cmp_request()], MyNodes::[merkle_tree:mt_node()],
  -                   [merkle_cmp_result()], RestTreeIn::[[merkle_tree:mt_node()]])
  -        -> {[merkle_cmp_result()], RestTreeOut::[merkle_tree:mt_node()]}.
  -p_check_node([], [], AccR, AccN) ->
  -    {lists:reverse(AccR), lists:append(lists:reverse(AccN))};
  -p_check_node([?omit | TK], [_Node | TN], AccR, AccN) ->
  -    p_check_node(TK, TN, AccR, AccN);
  -p_check_node([Hash | TK], [Node | TN], AccR, AccN) ->
  +-spec p_check_node(Hashes::[merkle_cmp_request()], 
  +                   MyNodes::NodeList,
  +                   [merkle_cmp_result()], 
  +                   RestTreeIn::[NodeList],
  +                   AccResolve::NodeList)
  +        -> {[merkle_cmp_result()], 
  +            RestTreeOut::NodeList,
  +            ResolveReq::NodeList}
  +    when 
  +      is_subtype(NodeList, [merkle_tree:mt_node()]).
  +p_check_node([], [], AccR, AccN, AccRes) ->
  +    {lists:reverse(AccR), lists:append(lists:reverse(AccN)), AccRes};
  +p_check_node([{ToOmit, Hash} | TK], [Node | TN], AccR, AccN, AccRes) ->
  +    OmitNodes = [Node | lists:sublist(TN, 1, ToOmit - 1)],
  +    ToResolve = merkle_get_sync_leafs(OmitNodes, Hash, []),
  +    p_check_node(TK, lists:nthtail(ToOmit - 1, TN), AccR, AccN, lists:append(ToResolve, AccRes));
  +p_check_node([Hash | TK], [Node | TN], AccR, AccN, AccRes) ->
       IsLeaf = merkle_tree:is_leaf(Node),
  -    case merkle_tree:get_hash(Node) =:= Hash of
  -        true when IsLeaf -> p_check_node(TK, TN, [?ok_leaf | AccR], AccN);
  -        true when not IsLeaf -> p_check_node(TK, TN, [?ok_inner | AccR], AccN);
  -        false when IsLeaf -> p_check_node(TK, TN, [?fail_leaf | AccR], AccN);
  +    NodeHash = merkle_tree:get_hash(Node),
  +    case NodeHash =:= Hash of
  +        true when IsLeaf -> p_check_node(TK, TN, [?ok_leaf | AccR], AccN, AccRes);
  +        true when not IsLeaf -> p_check_node(TK, TN, [?ok_inner | AccR], AccN, AccRes);
  +        false when IsLeaf -> p_check_node(TK, TN, [{?fail_leaf, NodeHash} | AccR], AccN, AccRes);
           false when not IsLeaf ->
               Childs = merkle_tree:get_childs(Node),
  -            p_check_node(TK, TN, [?fail_inner | AccR], [Childs | AccN])
  +            p_check_node(TK, TN, [?fail_inner | AccR], [Childs | AccN], AccRes)
       end.
   
   -spec process_tree_cmp_result([merkle_cmp_result()], merkle_tree:merkle_tree() | RestTree, pos_integer(), Stats) ->
  
positive.code: %% merkle tree sync messages
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  on({check_nodes, SenderPid, ToCheck}, State = #rr_recon_state{struct = Tree}) ->
      {Result, RestTree} = check_node(ToCheck, Tree),
      send(SenderPid, {check_nodes_response, Result}),
      State#rr_recon_state{dest_recon_pid = SenderPid, struct = RestTree};
  
  on({check_nodes, ToCheck},
     State = #rr_recon_state{struct = Tree, dest_recon_pid = SenderPid}) ->
      ?ASSERT(comm:is_valid(SenderPid)),
      {Result, RestTree} = check_node(ToCheck, Tree),
      send(SenderPid, {check_nodes_response, Result}),
      State#rr_recon_state{struct = RestTree};
  
  on({check_nodes_response, CmpResults}, State =
         #rr_recon_state{ dest_recon_pid = DestReconPid,
  
negative.code:                                       Res,
                                        lists:reverse(Childs, RTree));
          true -> 
              NewReq = [{BS, merkle_tree:get_hash(Node)} | Req],
              p_process_tree_cmp_result(TR, TN, BS, Stats, NewReq, [Node | Res], RTree)
      end.
  
  %% @doc Gets all leaves in the given merkle node list whose hash =/= skipHash. 
  -spec merkle_get_sync_leafs(Nodes::NodeL, Skip::Hash, LeafAcc::NodeL) -> ToSync::NodeL 
      when 
        is_subtype(Hash,  merkle_tree:mt_node_key()),
        is_subtype(NodeL, [merkle_tree:mt_node()]).
  merkle_get_sync_leafs([], _Skip, ToSyncAcc) ->
      ToSyncAcc;
  merkle_get_sync_leafs([Node | Rest], Skip, ToSyncAcc) ->
      case merkle_tree:is_leaf(Node) of
          true  ->
              case merkle_tree:get_hash(Node) =:= Skip of
                  true  -> merkle_get_sync_leafs(Rest, Skip, ToSyncAcc);
                  false -> merkle_get_sync_leafs(Rest, Skip, [Node | ToSyncAcc])
              end;
          false ->
              merkle_get_sync_leafs(
                lists:append(merkle_tree:get_childs(Node), Rest), Skip, ToSyncAcc)
      end.
  
  %% @doc Starts a single resolve request for all given leave nodes by joining
  %%      their intervals.
  %%      Returns the number of resolve requests (requests with feedback count 2).
  -spec resolve_leafs([merkle_tree:mt_node()], Dest::comm:mypid(),
                       rrepair:session_id(), OwnerLocal::comm:erl_local_pid())
          -> 0..2.
  resolve_leafs([], _Dest, _SID, _OwnerL) -> 0;
  resolve_leafs(Nodes, Dest, SID, OwnerL) ->
      resolve_leafs(Nodes, Dest, SID, OwnerL, intervals:empty(), 0).
  
  % @doc Returns number of caused resolve requests (requests with feedback count 2).
  -spec resolve_leafs([merkle_tree:mt_node()], Dest::comm:mypid(),
                       rrepair:session_id(), OwnerLocal::comm:erl_local_pid(),
                       Interval::intervals:interval(), Items::non_neg_integer())
          -> 0..2.
  resolve_leafs([Node | Rest], Dest, SID, OwnerL, Interval, Items) ->
      LeafInterval = merkle_tree:get_interval(Node),
      IntervalNew = intervals:union(Interval, LeafInterval),
      ItemsNew = Items + merkle_tree:get_item_count(Node),
      resolve_leafs(Rest, Dest, SID, OwnerL, IntervalNew, ItemsNew);
  resolve_leafs([], Dest, SID, OwnerL, Interval, Items) ->
      Options = [{feedback_request, comm:make_global(OwnerL)}],
      case intervals:is_empty(Interval) of
          true -> 0;
  