anchor.diff:    lists:reverse(process_frames(continue_message, Frames, [Message | []])).
   
   -spec process_frames(Type:: message_type(), Frames :: list(#frame{}), Messages :: list(#message{})) -> list(#message{}).
  -process_frames(begin_message, [Frame | Frames], Acc) ->
  -  case process_frame(Frame, begin_message, #message{}) of
  +process_frames(_, [], Acc) ->
  +  Acc;
  +process_frames(begin_message, Frames, Acc) ->
  +  wtf(Frames, begin_message, #message{}, Acc);
  +
  +process_frames(continue_message, Frames, [FramgmentedMessage | Acc]) ->
  +  wtf(Frames, continue_message, FramgmentedMessage, Acc).
  +
  +wtf([Frame | Frames], Type, XMessage, Acc) ->
  +  case process_frame(Frame, Type, XMessage) of
       {fragmented, Message} ->
         process_frames(continue_message, Frames, [Message#message{type = fragmented} | Acc]);
       {completed, Message} ->
         process_frames(begin_message, Frames, [Message | Acc])
  -  end;
  -
  -process_frames(continue_message, [Frame | Frames], [FramgmentedMessage | Acc]) ->
  -  case process_frame(Frame, continue_message, FramgmentedMessage) of
  -    {fragmented, Message} ->
  -      process_frames(continue_message, Frames, [Message#message{type = fragmented} | Acc]);
  -    {completed, Message} ->
  -      process_frames(begin_message, Frames, [Message | Acc])
  -  end;
  -
  -process_frames(_, [], Acc) ->
  -  Acc.
  +  end.
   
   -spec process_frame(Frame :: #frame{}, MessageType :: message_type(), Message :: #message{})-> {fragmented | completed, #message{}}.
   process_frame(Frame, begin_message, Message) ->
  
positive.code: contatenate_payload_from_frames(Frames) ->
    contatenate_payload_from_frames(Frames, <<>>).
  
  contatenate_payload_from_frames([Frame | Rest], Acc) ->
    contatenate_payload_from_frames(Rest, <<Acc/binary, (Frame#frame.payload)/binary>>);
  
  contatenate_payload_from_frames([], Acc) ->
    Acc.
  
  -spec process(Frames ::list(#frame{}), Messages::list(#message{})) -> list(#message{}).
  process([Frame | Tail], Acc) ->
    Message = case Frame#frame.opcode of
      1 ->
        #message{type = text, payload = binary_to_list(Frame#frame.payload)};
      2 ->
        #message{type = binary, payload = Frame#frame.payload}
    end,
  
    process(Tail, [Message | Acc]);
  
  process([], Acc) ->
    Acc.
  
  
  %-spec process(Frames::list(#frame{}), IncompleteMessage::#message{}) -> {text | binary | control | fragmented, #message{}}.
  %process(Frames, IncompleteMessage) ->
  %  [Head | Tail] = Frames,
    
  %
  % Internal
  %
  -spec encode(Data::binary(), Type :: atom(), Acc ::list()) -> list().
  encode(<<Data:?FRAGMENT_SIZE/binary>>, Type, Acc) ->
    [frame(Data, [fin, {opcode, Type}]) | Acc];
  
  encode(<<Data:?FRAGMENT_SIZE/binary, Rest/binary>>, Type, []) ->
    encode(Rest, continuation, [frame(Data, [{opcode, Type}]) | []]);
  
  encode(<<Data:?FRAGMENT_SIZE/binary, Rest/binary>>, Type, Acc) ->
    encode(Rest, Type, [frame(Data, [{opcode, Type}]) | Acc]);
  
  encode(<<>>, _Type, Acc) ->
    Acc;
  
  encode(<<Data/binary>>, Type, Acc) ->
    [frame(Data, [fin, {opcode, Type}]) | Acc].
  
  -spec frame(Data::binary(), Options::list()) -> binary().
  frame(Data, Options) ->
    Frame = wsecli_framing:frame(Data, Options),
    wsecli_framing:to_binary(Frame).
  
  
negative.code: decode(Data, Message) ->
    decode(Data, continue_message, Message).
  
  
  %
  % Internal
  %
  -spec encode(Data::binary(), Type :: atom(), Acc ::list()) -> list().
  encode(<<Data:?FRAGMENT_SIZE/binary>>, Type, Acc) ->
    [frame(Data, [fin, {opcode, Type}]) | Acc];
  
  encode(<<Data:?FRAGMENT_SIZE/binary, Rest/binary>>, Type, []) ->
    encode(Rest, continuation, [frame(Data, [{opcode, Type}]) | []]);
  
  encode(<<Data:?FRAGMENT_SIZE/binary, Rest/binary>>, Type, Acc) ->
    encode(Rest, Type, [frame(Data, [{opcode, Type}]) | Acc]);
  
  encode(<<>>, _Type, Acc) ->
    Acc;
  
  encode(<<Data/binary>>, Type, Acc) ->
    [frame(Data, [fin, {opcode, Type}]) | Acc].
  
  -spec frame(Data::binary(), Options::list()) -> binary().
  frame(Data, Options) ->
    Frame = wsecli_framing:frame(Data, Options),
    wsecli_framing:to_binary(Frame).
  
  -spec decode(Data::binary(), Type :: message_type(), Message::#message{}) -> list(#message{}).
  decode(Data, begin_message, _Message) ->
    Frames = wsecli_framing:from_binary(Data),
  