anchor.diff:          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">>],
  -        {reply, {lists:max(Counts), StatColumns, StatsRows, atom_to_binary(SN, utf8)}, SN, State, infinity}
  +        {next_state, SN, State, [{reply, From, {lists:max(Counts), StatColumns, StatsRows, atom_to_binary(SN, utf8)}}]}
       catch
           _:Error ->
  -            {reply, {error, iolist_to_binary(io_lib:format("~p", [Error])), erlang:get_stacktrace()}
  -                  , SN, State, infinity}
  +            {next_state, SN, State, [{reply, From, {error, iolist_to_binary(io_lib:format("~p", [Error])), erlang:get_stacktrace()}}]}
       end;
  -handle_sync_event({distinct_count, ColumnId}, _From, SN, #state{nav = Nav, tableId = TableId, indexId = IndexId, rowFun = RowFun, ctx=#ctx{stmtCols=StmtCols}} = State) ->
  +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
  
positive.code: %% Only data input from DB and button events for <<">|">>, <<">|...">> and <<"...">> handled here
  %% Other buttons and commands are handled through all_state_event in handle_event/3
  
  empty({button, <<">|">>, ReplyTo}, State0) ->
      % start fetch
      State1 = fetch(push,none, State0#state{tailMode=false}),
      {next_state, autofilling, State1#state{stack={button,<<">|">>,ReplyTo}}};
  empty({button, <<">|...">>, ReplyTo}, State0) ->
      % start fetch, schedule tail
      State1 = fetch(push,true, State0#state{tailMode=true,tailLock=false}),
      {next_state, autofilling, State1#state{stack={button,<<">|...">>,ReplyTo}}};
  empty({button, <<"...">>, ReplyTo}, State0) ->
      % skip fetch, schedule tail
      State1 = fetch(skip,true, State0#state{tailMode=true,tailLock=false}),
      {next_state, tailing, State1#state{stack={button,<<"...">>,ReplyTo}}};
  empty({button, <<"pt">>, ReplyTo}, #state{nav=ind}=State0) ->
      % reject command because of uncommitted changes
      State1 = gui_nop(#gres{state=empty,beep=true,message= ?PtNoSort},State0#state{replyToFun=ReplyTo}),
      {next_state, empty, State1};
  empty({button, <<"pt">>, ReplyTo}, State0) ->
      % passthrough, schedule tail
      State1 = fetch(push,true, State0#state{tailMode=true,tailLock=false}),
      {next_state, passthrough, State1#state{stack={button,<<"pt">>,ReplyTo}}};
  empty(Other, State) ->
      ?Info("empty -- unexpected erlimem_fsm event ~p in empty state", [Other]),
      {next_state, empty, State}.
  
  filling({button, <<"restart">>, ReplyTo}, #state{bl=BL,guiTop=GuiTop,guiCol=true}=State0) ->
      State1 = reply_stack(filling, ReplyTo, State0),
      State2 = gui_replace_from(GuiTop,BL,#gres{state=filling,focus=1},State1),
      {next_state, filling, State2#state{tailMode=false}};
  filling({button, <<"restart">>, ReplyTo}, #state{dirtyCnt=DC}=State0) when DC==0 ->
      State1 = reply_stack(filling, ReplyTo, State0),
      State2 = fetch_close(State1),
      State3 = data_clear(State2),
      State4 = fetch(none,none,State3),
      State5 = gui_clear(#gres{state=filling,loop= <<">">>}, State4),
      {next_state, filling, State5#state{tailMode=false}};
  filling({button, <<"restart">>, ReplyTo}, State0) ->
      % reject command because of uncommitted changes
      State1 = gui_nop(#gres{state=filling,beep=true,message= ?MustCommit},State0#state{replyToFun=ReplyTo}),
      {next_state, filling, State1};
  filling({button, Button, ReplyTo}=Cmd, #state{bufCnt=0}=State0) ->
      % too quick, defer request .. when we have the first block of data
      State1 = reply_stack(filling, ReplyTo, State0),
      State2 = prefetch(filling,State1),
      ?NoDbLog(debug, [], "filling stack ~p", [Button]),
      {next_state, filling, State2#state{stack=Cmd}};
  filling({button, <<"...">>, ReplyTo}, #state{dirtyCnt=DC}=State0) when DC==0 ->
      % close fetch and clear buffers, schedule tail mode
      State1 = reply_stack(filling, ReplyTo, State0),
      State2 = fetch_close(State1),
  
negative.code:     DistinctCountColumns = ColInfo ++
          [#stmtCol{alias = <<"count">>, type = float, readonly = true}
          ,#stmtCol{alias = <<"pct">>, type = float, readonly = true}],
      {next_state, SN, State, [{reply, From, {Total, DistinctCountColumns, DistinctCountRowsWithId, atom_to_binary(SN, utf8)}}]};
  handle_call({distinct_statistics, 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
  