anchor.diff:  %%% API
   %%%===================================================================
   
  -%%--------------------------------------------------------------------
  -%% @doc
  -%% Creates a gen_fsm process which calls Module:init/1 to
  -%% initialize. To ensure a synchronized start-up procedure, this
  -%% function does not return until Module:init/1 has returned.
  -%%
  -%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
  -%% @end
  -%%--------------------------------------------------------------------
   start_link(WTPControlChannelAddress) ->
  -    gen_fsm:start_link(?MODULE, [WTPControlChannelAddress], [{debug, ?DEBUG_OPTS}]).
  +    gen_statem:start_link(?MODULE, [WTPControlChannelAddress], [{debug, ?DEBUG_OPTS}]).
   
   handle_packet(WTPControlChannelAddress, Packet) ->
       try
  
positive.code: cancel_retransmit(State = #state{retransmit_timer = undefined}) ->
      State;
  cancel_retransmit(State = #state{retransmit_timer = Timer}) ->
      gen_fsm:cancel_timer(Timer),
      State#state{retransmit_timer = undefined}.
  
  queue_request(State = #state{request_queue = Queue}, Request) ->
  
negative.code:     State1 = send_request(Header1, configuration_update_request, ReqElements, State),
      next_state(run, State1);
  
  run(info, Event = {group_rekey, WlanIdent}, State0) ->
      lager:warning("in RUN got GTK rekey: ~p", [Event]),
      Wlan = get_wlan(WlanIdent, State0),
      State = start_gtk_rekey(WlanIdent, Wlan, State0),
      next_state(run, State);
  
  run(cast, Event = {gtk_rekey_done, WlanIdent}, State0) ->
      lager:warning("in RUN got GTK rekey DONE: ~p", [Event]),
      Wlan = get_wlan(WlanIdent, State0),
      State = finish_gtk_rekey(WlanIdent, Wlan, State0),
      next_state(run, State);
  
  run(cast, Event, State) ->
      handle_event(Event, run, State);
  
  run(info, Info, State) ->
      handle_info(Info, run, State).
  
  handle_event(station_detaching, StateName, State=#state{id = WtpId, station_count = SC}) ->
      if SC == 0 ->
              lager:error("Station counter and stations got out of sync", []),
  