anchor.diff:  % type definitions
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
  --type method()         :: bloom | merkle_tree | art | undefined.
  +-type method()         :: bloom | merkle_tree | art | iblt | undefined.
   -type recon_stage()    :: req_shared_interval | res_shared_interval | build_struct | reconciliation.
   -type exit_reason()    :: empty_interval | {ok, atom()}.
   
  
positive.code: 
  on({get_chunk_response, {RestI, DBList}}, State =
         #ru_recon_state{ recon_stage = build_struct,
                          recon_method = bloom,        
                          recon_struct = Params,                    
                          sync_round = Round,
                          dhtNodePid = DhtNodePid,
                          ownerRemotePid = MyRU_Pid,
                          sync_master = SyncMaster,
                          stats = Stats }) ->
      MyI = proplists:get_value(interval, Params),
      %Get Interval of DBList/Chunk
      %TODO: IMPROVEMENT getChunk should return ChunkInterval (db is traversed twice! - 1st getChunk, 2nd here)    
      ChunkI = mapInterval(MyI, 1),
      case intervals:is_empty(RestI) of
          false ->
              ?TRACE2("FORK RECON", []),
              {ok, Pid} = fork_recon(State, Round),
              send_chunk_req(DhtNodePid, Pid, RestI, 
                             mapInterval(RestI, get_interval_quadrant(ChunkI)), 
                             get_max_items(bloom));
          _ -> ok
      end,
      {BuildTime, SyncStruct} = 
          util:tc(fun() -> build_recon_struct(bloom, {ChunkI, DBList}, {get_fpr()}) end),
      case SyncMaster of
          true ->
              DestKey = select_sync_node(MyI),
              comm:send_local(DhtNodePid, 
                              {lookup_aux, DestKey, 0, 
                               {send_to_group_member, rep_upd, 
                                {request_recon, MyRU_Pid, Round, false, reconciliation, bloom, SyncStruct}}}),
              ?TRACE("BLOOM SEND RECON REQUEST TO Key: ~p", [DestKey]),
              comm:send_local(self(), {shutdown, {ok, build_struct}});
          _ -> ok
      end,
      State#ru_recon_state{ recon_struct = SyncStruct, 
                            stats = ru_recon_stats:set([{build_time, BuildTime}], Stats) };
  
  on({get_chunk_response, {RestI, DBList}}, State = 
         #ru_recon_state{ recon_stage = build_struct,
                          recon_method = merkle_tree,
                          sync_pid = SrcPid,
                          recon_struct = Params,
                          sync_master = IsMaster,
                          dest_ru_pid = DestRU_Pid,
                          ownerRemotePid = OwnerPid,
                          dhtNodePid = DhtNodePid,
                          sync_round = Round,
                          stats = Stats })  ->
      {BuildTime, MerkleTree} = 
          case merkle_tree:is_merkle_tree(Params) of
              true -> %extend tree
                  {BTime, NTree} = util:tc(fun() -> add_to_tree(DBList, Params) end),
                  {ru_recon_stats:get(build_time, Stats) + BTime, merkle_tree:gen_hash(NTree) };
              false -> %build new tree
                  Interval = proplists:get_value(interval, Params),
                  util:tc(fun() -> build_recon_struct(merkle_tree, 
                                                      {Interval, DBList}, 
                                                      {}) 
                          end)
          end,
      case intervals:is_empty(RestI) of
          false ->
              ?TRACE("TREE EXISTS - ADD REST - RestI=~p", [RestI]),
              send_chunk_req(DhtNodePid, self(), RestI, RestI, get_max_items(merkle_tree)),%MappedI is wrong
              State#ru_recon_state{ recon_struct = MerkleTree, 
                                    stats = 
                                        ru_recon_stats:set([{build_time, BuildTime}], 
                                                           Stats) };        
          true ->
              case IsMaster of
                  true ->
                      ?TRACE("MASTER SENDS ROOT CHECK", []),
                      comm:send(SrcPid, 
                                {check_node, comm:this(), 
                                 merkle_tree:get_interval(MerkleTree), 
                                 merkle_tree:get_hash(MerkleTree)});
                  false -> 
                      comm:send(DestRU_Pid, 
                                {request_recon, OwnerPid, Round, true, 
                                 res_shared_interval, merkle_tree,
                                 [{interval, merkle_tree:get_interval(MerkleTree)},
                                  {senderPid, comm:this()}] 
                                })
              end,
              NewStats = ru_recon_stats:set(
                           [{tree_compareLeft, ?IIF(IsMaster, 1, 0)},
                            {tree_size, merkle_tree:size_detail(MerkleTree)},
                            {build_time, BuildTime}], Stats), 
              State#ru_recon_state{ recon_stage = reconciliation, 
                                    recon_struct = MerkleTree, 
                                    stats = NewStats
                                  }          
      end;
  
  on({get_chunk_response, {[], DBList}}, State = 
         #ru_recon_state{ recon_stage = build_struct, 
                          recon_method = art,
                          recon_struct = Params,
                          sync_master = IsMaster,
                          ownerRemotePid = OwnerPid,
                          dest_ru_pid = DestRU_Pid,
                          sync_round = Round,
                          stats = Stats })  ->
      ToBuild = ?IIF(IsMaster, merkle_tree, art),
      Interval = proplists:get_value(interval, Params),
      {BuildTime, NewStruct} =
          util:tc(fun() -> build_recon_struct(ToBuild, {Interval, DBList}, {}) end),    
      NewStats = 
          case IsMaster of
              true -> 
                  %TODO measure sync time
                  {ok, ARStats} = 
                      art_recon(NewStruct, proplists:get_value(art, Params), State),
                  comm:send_local(self(), {shutdown, sync_finished}),
                  ru_recon_stats:set([{build_time, BuildTime},
                                      {tree_size, merkle_tree:size_detail(NewStruct)}], 
                                     ARStats);
              false ->
                  comm:send(DestRU_Pid, 
                            {request_recon, OwnerPid, Round, true, 
                             res_shared_interval, art,
                             [{interval, art:get_interval(NewStruct)},
                              {senderPid, comm:this()},
                              {art, NewStruct}]
                            }),
                  comm:send_local(self(), {shutdown, client_art_send}),
                  ru_recon_stats:set([{build_time, BuildTime}], Stats)
          end,    
      State#ru_recon_state{ recon_stage = reconciliation, 
                            recon_struct = NewStruct, 
                            stats = NewStats };
      
  on({get_chunk_response, {RestI, DBList}}, State = 
         #ru_recon_state{ recon_stage = reconciliation,
  
negative.code:     Intersection = intervals:intersection(MyIMapped, SrcIMapped),
      case intervals:is_empty(Intersection) of
          true ->
              comm:send_local(self(), {shutdown, intersection_empty});
          false ->
              MyIntersec = mapInterval_to_range(Intersection, MyInterval, 2),
  