anchor.diff:             #data{connection_states = #{current_write := Write}} = StateData) ->
       {next_state, handshake, StateData, [{reply, From, {ok, Write}}]};
   connection({call, From}, {application_data, AppData}, 
  -           #data{socket_options = SockOpts} = StateData) ->                   
  -    case encode_packet(AppData, SockOpts) of
  +           #data{socket_options = #socket_options{packet = Packet}} =
  +               StateData) ->
  +    case encode_packet(Packet, AppData) of
           {error, _} = Error ->
               {next_state, ?FUNCTION_NAME, StateData, [{reply, From, Error}]};
           Data ->
  
positive.code:                  tracker = Tracker} = StateData) ->
      TLSSocket = Connection:socket([Pid, self()], Transport, Socket, Connection, Tracker),
      {next_state, ?FUNCTION_NAME, StateData, [{reply, From, {ok, TLSSocket}}]};
  connection({call, From}, {dist_handshake_complete, _Node, DHandle}, #data{connection_pid = Pid} = StateData) ->
      ok = erlang:dist_ctrl_input_handler(DHandle, Pid),
      ok = ssl_connection:dist_handshake_complete(Pid, DHandle),
      %% From now on we execute on normal priority
      process_flag(priority, normal),
      Events = dist_data_events(DHandle, []),
      {next_state, ?FUNCTION_NAME, StateData#data{dist_handle = DHandle}, [{reply, From, ok} | Events]};
  connection(cast, {ack_alert, #alert{} = Alert}, #data{connection_pid = Pid} =StateData0) ->
      StateData = send_tls_alert(Alert, StateData0),
      Pid ! {self(), ack_alert},
  
negative.code:                              renegotiate_at = RenegotiateAt} = StateData0) ->
      case time_to_renegotiate(Data, ConnectionStates0, RenegotiateAt) of
  	true ->
  	    ssl_connection:internal_renegotiation(Pid, ConnectionStates0),
              {next_state, handshake, StateData0, 
               [{next_event, internal, {application_packets, From, Data}}]};
  	false ->
  	    {Msgs, ConnectionStates} =
                  Connection:encode_data(
                    iolist_to_binary(Data), Version, ConnectionStates0),
              StateData = StateData0#data{connection_states = ConnectionStates},
  	    case Connection:send(Transport, Socket, Msgs) of
                  ok when DistHandle =/=  undefined ->
  