anchor.diff:      State4 = data_clear(State3),
       State5 = gui_clear(#gres{state=tailing,loop= <<"tail">>},State4),
       {next_state, tailing, State5#state{tailMode=true,tailLock=false}};
  -aborted({button, <<"...">>, ReplyTo}, State0) ->
  +aborted(cast, {button, <<"...">>, ReplyTo}, State0) ->
       % reject because of uncommitted changes
       State1 = gui_nop(#gres{state=aborted,beep=true,message= ?MustCommit},State0#state{replyToFun=ReplyTo}),
       {next_state, aborted, State1};
  -aborted({button, <<">|...">>, ReplyTo}, State0) ->
  +aborted(cast, {button, <<">|...">>, ReplyTo}, State0) ->
       % keep data (if any) and switch .. tail mode
       State1 = reply_stack(aborted, ReplyTo, State0),
       State2 = fetch(skip,true,State1),
       State3 = gui_clear(State2),
       State4 = gui_nop(#gres{state=tailing,loop= <<"tail">>},State3),
       {next_state, tailing, State4#state{tailMode=true,tailLock=false}};
  -aborted({button, <<">|">>, ReplyTo}, #state{bufCnt=0}=State0) ->
  +aborted(cast, {button, <<">|">>, ReplyTo}, #state{bufCnt=0}=State0) ->
       % reject command because we have no data
       State1 = reply_stack(aborted, ReplyTo, State0),
       State1 = gui_nop(#gres{state=aborted,beep=true},State1),
       {next_state, aborted, State1};
  -aborted({button, <<">|">>, ReplyTo}, #state{bl=BL,bufBot=BufBot}=State0) ->
  +aborted(cast, {button, <<">|">>, ReplyTo}, #state{bl=BL,bufBot=BufBot}=State0) ->
       % jump .. buffer bottom
       State1 = reply_stack(aborted, ReplyTo, State0),
       State2 = gui_replace_until(BufBot,BL,#gres{state=aborted},State1),
       {next_state, aborted, State2};
  -aborted({rows, _}, State) ->
  +aborted(cast, {rows, _}, State) ->
       % ignore unsolicited rows
       {next_state, aborted, State};
  -aborted(Other, State) ->
  -    ?Info("aborted -- unexpected event ~p", [Other]),
  -    {next_state, aborted, State}.
  -
  -passthrough({button, <<"restart">>, ReplyTo}, #state{dirtyCnt=DC}=State0) when DC==0 ->
  +aborted({call, From}, Msg, State) ->
  +    handle_call(Msg, From, aborted, State);
  +aborted(cast, Msg, State) ->
  +    handle_event(Msg, aborted, State);
  +aborted(info, Msg, State) ->
  +    handle_info(Msg, aborted, State).
  +
  +passthrough(cast, {button, <<"restart">>, ReplyTo}, #state{dirtyCnt=DC}=State0) when DC==0 ->
       State1 = reply_stack(passthrough, ReplyTo, State0),
       State2 = fetch_close(State1),
       State3 = data_clear(State2),
       State4 = fetch(none,true,State3),
       State5 = gui_clear(#gres{state=filling,loop= <<">">>}, State4),
       {next_state, filling, State5#state{tailMode=false}};
  -passthrough({button, <<"restart">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<"restart">>, ReplyTo}, State0) ->
       % reject command because of uncommitted changes
       State1 = gui_nop(#gres{state=passthrough,beep=true,message= ?MustCommit},State0#state{replyToFun=ReplyTo}),
       {next_state, passthrough, State1};
  -passthrough({button, <<"...">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<"...">>, ReplyTo}, State0) ->
       State1 = reply_stack(passthrough, ReplyTo, State0),
       State2 = gui_nop(#gres{state=passthrough,beep=true,message= ?PassThroughOnlyRestart},State1),
       {next_state, passthrough, State2};
  -passthrough({button, <<">|...">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<">|...">>, ReplyTo}, State0) ->
       State1 = reply_stack(passthrough, ReplyTo, State0),
       State2 = gui_nop(#gres{state=passthrough,beep=true,message= ?PassThroughOnlyRestart},State1),
       {next_state, passthrough, State2};
  -passthrough({button, <<">|">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<">|">>, ReplyTo}, State0) ->
       State1 = reply_stack(passthrough, ReplyTo, State0),
       State2 = gui_nop(#gres{state=passthrough,beep=true,message= ?PassThroughOnlyRestart},State1),
       {next_state, passthrough, State2};
  -passthrough({button, <<"pt">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<"pt">>, ReplyTo}, State0) ->
       % passthrough, schedule tail
       State1 = reply_stack(passthrough, ReplyTo, State0),
       {next_state, passthrough, State1#state{stack={button,<<"pt">>,ReplyTo}}};
  -passthrough({button, <<"tail">>, ReplyTo}=Cmd, #state{tailLock=false,bufBot=BufBot,guiBot=GuiBot}=State0) when GuiBot==BufBot ->
  +passthrough(cast, {button, <<"tail">>, ReplyTo}=Cmd, #state{tailLock=false,bufBot=BufBot,guiBot=GuiBot}=State0) when GuiBot==BufBot ->
       State1 = reply_stack(passthrough, ReplyTo, State0),
       {ok, NewTRef} = timer:send_after(?TAIL_TIMEOUT, cmd_stack_timeout),
       {next_state, passthrough, State1#state{stack=Cmd, tRef=NewTRef}};
  -passthrough({button, <<"tail">>, ReplyTo}, #state{tailLock=false}=State0) ->
  +passthrough(cast, {button, <<"tail">>, ReplyTo}, #state{tailLock=false}=State0) ->
       % continue passthrough
       State1 = reply_stack(passthrough, ReplyTo, State0),
       State2 = serve_bot(passthrough, <<"tail">>, State1),
       {next_state, passthrough, State2};
  -passthrough({button, <<"tail">>, ReplyTo}, State0) ->
  +passthrough(cast, {button, <<"tail">>, ReplyTo}, State0) ->
       % ignore loop command, stop passthrough
       State1 = gui_nop(#gres{state=passthrough},State0#state{replyToFun=ReplyTo}),
       {next_state, passthrough, State1};
  -passthrough({delete, {Recs,Complete}}, State0) ->
  +passthrough(cast, {delete, {Recs,Complete}}, State0) ->
       State1 = data_append(passthrough,{Recs,Complete,del},State0),
       {next_state, passthrough, State1#state{pfc=0}};
  -passthrough({rows, {Recs,Complete}}, State0) ->
  +passthrough(cast, {rows, {Recs,Complete}}, State0) ->
       State1 = data_append(passthrough,{Recs,Complete},State0),
       {next_state, passthrough, State1#state{pfc=0}};
  -passthrough(Other, State) ->
  -    ?Info("passthrough -- unexpected event ~p", [Other]),
  -    {next_state, passthrough, State}.
  +passthrough({call, From}, Msg, State) ->
  +    handle_call(Msg, From, passthrough, State);
  +passthrough(cast, Msg, State) ->
  +    handle_event(Msg, passthrough, State);
  +passthrough(info, Msg, State) ->
  +    handle_info(Msg, passthrough, State).
   
   
   %% --------------------------------------------------------------------
  
positive.code: 
  %% gen_fsm callbacks
  
  -export([ empty/2
          , filling/2
          , autofilling/2
          , completed/2
          , tailing/2
          , aborted/2
          , passthrough/2
          ]).
  
  -export([ init/1
          , handle_event/3
          , handle_sync_event/4
          , handle_info/3
          , terminate/3
          , code_change/4
          ]).
  
  -export([ filter_fun/1
  
negative.code:         StatsRows = [[Idx, nop | tuple_to_list(lists:nth(Idx, StatsRowsZipped))] || Idx <- lists:seq(1, length(Avgs))],
          ?Debug("Stat Rows ~p", [StatsRows]),
          StatColumns = [<<"column">>, <<"count">>, <<"min">>, <<"max">>, <<"sum">>, <<"avg">>, <<"median">>, <<"std_dev">>, <<"variance">>,<<"hash">>],
          {next_state, SN, State, [{reply, From, {lists:max(Counts), StatColumns, StatsRows, atom_to_binary(SN, utf8)}}]}
      catch
          _:Error ->
              {next_state, SN, State, [{reply, From, {error, iolist_to_binary(io_lib:format("~p", [Error])), erlang:get_stacktrace()}}]}
      end;
  handle_call({distinct_count, ColumnId}, From, SN, #state{nav = Nav, tableId = TableId, indexId = IndexId, rowFun = RowFun, ctx=#ctx{stmtCols=StmtCols}} = State) ->
      case Nav of
          raw -> TableUsed = TableId;
          _ ->   TableUsed = IndexId
  