anchor.diff:      case dict:find(MessageId, WAcks) of
           error ->
               State;
  -        {ok, Item} ->
  -            {QoS, Bin, _, MsgStoreRef} =
  -            case Item of
  -                {_, #mqtt_frame{fixed=Fixed} = Frame, _, _} = Item ->
  -                    NewBin = emqtt_frame:serialise(
  -                               Frame#mqtt_frame{
  -                                 fixed=Fixed#mqtt_frame_fixed{
  -                                         dup=true
  -                                        }}),
  -                    setelement(2, Item, NewBin);
  -                _ -> Item
  -            end,
  +        {ok, {QoS, #mqtt_frame{fixed=Fixed} = Frame, _, MsgStoreRef}} ->
  +            Bin = emqtt_frame:serialise(
  +                    Frame#mqtt_frame{
  +                      fixed=Fixed#mqtt_frame_fixed{
  +                              dup=true
  +                             }}),
               SendFun(Bin),
               vmq_systree:incr_messages_sent(),
               Ref = send_after(RetryInterval, {retry, MessageId}),
               State#state{waiting_acks=dict:store(MessageId,
  -                                                {QoS, Bin, Ref, MsgStoreRef},
  +                                                {QoS, Frame, Ref, MsgStoreRef},
                                                   WAcks)}
       end,
       ret({connected, NewState});
  
positive.code:                         ok ->
                              vmq_hook:all(on_register, [Peer, ClientId, User, Password]),
                              check_will(F, State#state{username=User});
                          {error, _Reason} ->
                              {connection_attempted,
                               send_connack(?CONNACK_SERVER, State)}
                      end;
                  not_found ->
                      % returned when no hook on_register hook was
                      % able to authenticate user
                      {connection_attempted,
                       send_connack(?CONNACK_AUTH, State)};
                  {error, invalid_credentials} ->
                      {connection_attempted,
                       send_connack(?CONNACK_CREDENTIALS, State)};
                  {error, not_authorized} ->
                      {connection_attempted,
                       send_connack(?CONNACK_AUTH, State)}
              end;
  
negative.code:         ok ->
              vmq_hook:all(on_register, [Peer, ClientId, undefined, undefined]),
              check_will(F, State#state{clean_session=CleanSession});
          {error, Reason} ->
              lager:error("can't register client ~p due to ~p", [ClientId, Reason]),
              {connection_attempted,
               send_connack(?CONNACK_SERVER, State)}
      end;
  