anchor.diff:  %% Increment a stats counter for result codes in incoming and outgoing
   %% answers.
   
  +%% Message sent as a header/avps list.
  +incr_result(send = Dir,
  +            #diameter_packet{msg = [#diameter_header{} = H | _]}
  +            = Pkt,
  +            TPid,
  +            DictT) ->
  +    incr_res(Dir, Pkt#diameter_packet{header = H}, TPid, DictT);
  +
   %% Outgoing message as binary: don't count. (Sending binaries is only
   %% partially supported.)
  -incr_result(_, #diameter_packet{msg = undefined = No}, _, _) ->
  +incr_result(send, #diameter_packet{header = undefined = No}, _, _) ->
       No;
   
   %% Incoming or outgoing. Outgoing with encode errors never gets here
   %% since encode fails.
  -incr_result(Dir, Pkt, TPid, {MsgDict, AppDict, Dict0}) ->
  -    #diameter_packet{header = #diameter_header{is_error = E}
  -                            = Hdr,
  -                     errors = Es}
  -        = Pkt,
  +incr_result(Dir, Pkt, TPid, DictT) ->
  +    incr_res(Dir, Pkt, TPid, DictT).
  +
  +incr_res(Dir,
  +         #diameter_packet{header = #diameter_header{is_error = E}
  +                          = Hdr,
  +                          errors = Es}
  +         = Pkt,
  +         TPid,
  +         DictT) ->
  +    {MsgDict, AppDict, Dict0} = DictT,
   
       Id = msg_id(Hdr, AppDict),
       %% Could be {relay, 0}, in which case the R-bit is redundant since
  
positive.code:     answer_message(RC, Caps, Dict0, Pkt).
  
  %% msg_dict/3
  
  %% An incoming answer, not yet decoded.
  msg_dict(AppDict, Dict0, #diameter_packet{header
                                        = #diameter_header{is_request = false,
                                                           is_error = E},
                                        msg = undefined}) ->
      if E -> Dict0; true -> AppDict end;
  
  msg_dict(AppDict, Dict0, [Msg]) ->
      msg_dict(AppDict, Dict0, Msg);
  
  msg_dict(AppDict, Dict0, #diameter_packet{msg = Msg}) ->
      msg_dict(AppDict, Dict0, Msg);
  
  msg_dict(AppDict, Dict0, Msg) ->
      choose(is_answer_message(Msg, Dict0), Dict0, AppDict).
  
  is_answer_message([Name | _], _) ->
      Name == 'answer-message';
  
  is_answer_message(Rec, Dict) ->
      try
          'answer-message' == Dict:rec2msg(element(1,Rec))
  
negative.code: %%   applications MUST include either one Result-Code AVP or one
  %%   Experimental-Result AVP.
  
  rc_counter(Dict, Dir, #diameter_packet{header = H,
                                         avps = As,
                                         msg = Msg})
    when Dir == recv;         %% decoded incoming
         Msg == undefined ->  %% relayed outgoing
      rc_counter(Dict, [H|As]);
  
  rc_counter(Dict, _, #diameter_packet{msg = Msg}) ->
  