anchor.diff:  -spec check_round(OtherRound::non_neg_integer(), CBModule::module(), State::state())
       -> ok | start_new_round | enter_new_round | propagate_new_round.
   check_round(OtherRound, CBModule, State) ->
  -    MyRound = get_round(CBModule, State),
  -    Leader = is_leader(get_range(State)),
  +    MyRound = state_get(round, CBModule, State),
  +    Leader = is_leader(state_get(range, State)),
       case MyRound =:= OtherRound of
           true when Leader ->
               case is_end_of_round(CBModule, State) of
                   true ->
  -                    inc_round(CBModule, State),
  -                    set_cycles(0, CBModule, State),
  +                    state_update(round, fun (X) -> X+1 end, CBModule, State),
  +                    state_set(cycles, 0, CBModule, State),
                       start_new_round;
                   false -> ok
               end;
           true -> ok;
           false when MyRound < OtherRound ->
  -            set_round(OtherRound, CBModule, State),
  -            set_cycles(0, CBModule, State),
  +            state_set(round, OtherRound, CBModule, State),
  +            state_set(cycles, 0, CBModule, State),
               enter_new_round;
           false when MyRound > OtherRound ->
               propagate_new_round
  
positive.code:                     _ = cb_call(integrate_data, [QData, current_round, OtherRound], Msg, CBModule, State);
                  start_new_round -> % self is leader
                      log:log(?SHOW, "[ Gossip ] Starting a new round p2p_exch_reply"),
                      _ = cb_call(notify_change, [new_round, get_round(CBModule, State)], Msg, CBModule, State),
                      _ = cb_call(integrate_data, [QData, old_round, OtherRound], Msg, CBModule, State),
                      comm:send(SourcePid, {new_round, CBModule, get_round(CBModule, State)});
                  enter_new_round ->
                      log:log(?SHOW, "[ Gossip ] Entering a new round p2p_exch_reply"),
                      _ = cb_call(notify_change, [new_round, get_round(CBModule, State)], Msg, CBModule, State),
                      _ = cb_call(integrate_data, [QData, current_round, OtherRound], Msg, CBModule, State);
                  propagate_new_round -> % i.e. MyRound > OtherRound
                      log:log(debug, "[ Gossip ] propagate round in p2p_exch_reply"),
                      comm:send(SourcePid, {new_round, CBModule, get_round(CBModule, State)}),
                      _ = cb_call(integrate_data, [QData, old_round, OtherRound], Msg, CBModule, State)
              end
      end,
  
negative.code: % Getters and Setters
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  
  
  
  %% @doc Gets the given key from the given state.
  %%      Allowed keys:
  %%      <ul>
  %%        <li>`cb_modules', a list of registered callback modules ,</li>
  %%        <li>`msg_queue', the message queue of the behaviour module, </li>
  %%        <li>`range', the key range of the node, </li>
  %%        <li>`{reply_peer, Ref}', the peer to send the p2p_exch_reply to, </li>
  %%        <li>`{trigger_group, TriggerInterval}', trigger group, </li>
  %%      </ul>
  -spec state_get(Key::state_key(), State::state()) -> any().
  state_get(Key, State) ->
      case ?PDB:get(Key, State) of
          {Key, Value} -> Value;
          undefined ->
              log:log(error, "[ gossip2 ] Lookup of ~w in ~w failed", [Key, State]),
              error(lookup_failed, [Key, State])
      end.
  
  -spec state_get_raw(Key::state_key(), State::state()) -> any().
  state_get_raw(Key, State) ->
      case ?PDB:get(Key, State) of
          {Key, Value} -> Value;
          undefined -> undefined
      end.
  
  
  -spec state_take(Key::state_key(), State::state()) -> any().
  state_take(Key, State) ->
      case ?PDB:take(Key, State) of
          {Key, Value} -> Value;
          undefined ->
              log:log(error, "[ gossip2 ] Take of ~w in ~w failed", [Key, State]),
              error(lookup_failed, [Key, State])
      end.
  
  -spec state_set(Key::state_key(), Value::any(), State::state()) -> any().
  state_set(Key, Value, State) ->
      ?PDB:set({Key, Value}, State), State.
  
  
  %% @doc Gets the given key from the given state.
  %%      Allowed keys:
  %%      <ul>
  %%        <li>`cb_state', the state of the given callback module, </li>
  %%        <li>`cb_status', indicates, if `init()' was called on callback module, </li>
  %%        <li>`exch_data', a tuple of the data to exchange and the peer to
  %%                  exchange the data with. Can be one of the following: </li>
  %%          <ul>
  %%            <li>`{undefined, undefined}'</li>
  %%            <li>`{undefined, Peer::comm:mypid()}'</li>
  %%            <li>`{ExchData::any(), undefined}'</li>
  %%            <li>`{ExchData::any(), Peer::comm:mypid()}'</li>
  %%          </ul>
  %%        <li>`round', the round of the given callback, </li>
  %%        <li>`cycle_status', the cycle status, </li>
  %%        <li>`cycles', cycle counter, </li>
  %%      </ul>
  -spec state_get(Key::state_key_cb(), CBModule::module(), State::state()) -> any().
  state_get(Key, CBModule, State) ->
      state_get({Key, CBModule}, State).
  
  %% @doc Sets the given value for the given key in the given state.
  %%      Allowed keys see state_get/3
  %% @todo refactor cycle_status (-> its not cycle, but prepare_phase)
  -spec state_set(Key::state_key_cb(), Value::any(), CBModule::module(), State::state()) -> state().
  state_set(Key, Value, CBModule, State) ->
      state_set({Key, CBModule}, Value, State).
  
  
  -spec state_update(Key::state_key_cb(), UpdateFun::fun(), CBModule::module(), State::state()) -> state().
  state_update(Key, Fun, CBModule, State) ->
      Value = apply(Fun, [state_get(Key, CBModule, State)]),
      state_set(Key, Value, CBModule, State).
  
  
  %% Message Queue %%
  
  -spec msg_queue_add(Msg::message(), State::state()) -> state().
  msg_queue_add(Msg, State) ->
      MsgQueue = case state_get_raw(msg_queue, State) of
          undefined -> msg_queue:new();
          CurrentMsgQueue -> CurrentMsgQueue
      end,
      NewMsgQueue = msg_queue:add(MsgQueue, Msg),
      state_set(msg_queue, NewMsgQueue, State).
  
  
  -spec msg_queue_send(State::state()) -> state().
  msg_queue_send(State) ->
      NewMsgQueue = case state_get_raw(msg_queue, State) of
          undefined -> msg_queue:new();
          MsgQueue ->
              msg_queue:send(MsgQueue),
              msg_queue:new()
      end,
      state_set(msg_queue, NewMsgQueue, State).
  
  
  -spec get_source_pid({p2p_exch, CBModule::module(), SourcePid::comm:mypid(),
  