anchor.diff:      Payload/binary>>}) ->
   
       {ok,ClientId, Rest} = parse_string(S#parse_state{buffer=Payload}), %% 3.1.3.1 does not place strict limitations on the ClientId
  -    {ok, WillDetails,Rest3} = parse_will_details_maybe(WillFlag,WillRetain,WillQoS,Rest),
  -    {Username,Rest4} = parse_string_maybe(UsernameFlag,Rest3),
  -    {Password,<<>>} =  parse_string_maybe(PasswordFlag,Rest4),
  +    {ok, WillDetails,Rest3} = maybe_parse_will_details(WillFlag,WillRetain,WillQoS,Rest),
  +    {Username,Rest4} = maybe_parse_string(UsernameFlag,Rest3),
  +    {Password,<<>>} =  maybe_parse_string(PasswordFlag,Rest4),
       #'CONNECT'{
           protocol_name = ProtocolName,
           protocol_version = ProtocolLevel,
  
positive.code:     end.
  
  read(S = #parse_state{max_buffer_size = MaxBufferSize, buffer = Buffer, readfun = ReadFun}) ->
      S#parse_state{ buffer =  read(ReadFun, MaxBufferSize, Buffer)}.
  
  %% ========================================================
  %%      PRIMITIVES:
  
negative.code: 
  parse_specific_type(?PUBLISH,<<Dup:1,QoS:2,Retain:1>>,S) when QoS =< 2 ->
  
      %% validate flags - @todo: should we do that here? or in the connection process???
      case {Dup,QoS,Retain} of
          {1,0,_}->
              throw({error,invalid_flags});
  