anchor.diff:  % update_bag(IsSec, SKey, Table, ColMap, [C|CList]) ->
   %     ?UnimplementedException({"Cursor update not supported for bag tables",Table}).
   
  +receive_raw() ->
  +    receive_raw(50, []).
  +
  +receive_raw(Timeout) ->
  +    receive_raw(Timeout, []).
  +
  +receive_raw(Timeout,Acc) ->    
  +    case receive 
  +            R ->    io:format(user, "~p got:~n~p~n", [erlang:now(),R]),
  +                    R
  +        after Timeout ->
  +            stop
  +        end of
  +        stop ->     lists:reverse(Acc);
  +        Result ->   receive_raw(Timeout,[Result|Acc])
  +    end.
  +
  +receive_list(StmtRef,Complete) ->
  +    receive_list(StmtRef,Complete,50,[]).
  +
  +receive_list(StmtRef,Complete, Timeout) ->
  +    receive_list(StmtRef,Complete,Timeout,[]).
  +
  +receive_list(StmtRef,Complete,Timeout,Acc) ->    
  +    case receive
  +            R ->    % io:format(user, "~p got:~n~p~n", [erlang:now(),R]),
  +                    R
  +        after Timeout ->
  +            stop
  +        end of
  +        stop ->     
  +            Unchecked = case Acc of
  +                [] ->                       
  +                    [{StmtRef,[],Complete}];
  +                [{StmtRef,{_,Complete}}|_] -> 
  +                    lists:reverse(Acc);
  +                [{StmtRef,{L1,C1}}|_] ->      
  +                    throw({bad_complete,{StmtRef,{L1,C1}}});
  +                Res ->                      
  +                    throw({bad_receive,lists:reverse(Res)})
  +            end,
  +            case lists:usort([element(1, SR) || SR <- Unchecked]) of
  +                [StmtRef] ->                lists:flatten([element(1,element(2, T)) || T <- Unchecked]);
  +                StmtRefs ->                 throw({bad_stmtref,lists:delete(StmtRef, StmtRefs)})
  +            end;
  +        Result ->   
  +            receive_list(StmtRef,Complete,Timeout,[Result|Acc])
  +    end.
  +
  +result_lists(List,RowFun) when is_list(List), is_function(RowFun) ->  
  +    lists:map(RowFun,List).
  +
  +result_tuples(List,RowFun) when is_list(List), is_function(RowFun) ->  
  +    [list_to_tuple(R) || R <- lists:map(RowFun,List)].
  +
   %% --Interface functions  (calling imem_if for now, not exported) ---------
   
   if_call_mfa(IsSec,Fun,Args) ->
  
positive.code:     {_Schema,Table,_Alias} = hd(Stmt#statement.tables),
      catch if_call_mfa(false,unsubscribe,[none,{table,Table,simple}]).
  
  kill_fetch(MonitorRef, Pid) ->
      catch erlang:demonitor(MonitorRef, [flush]),
      catch Pid ! abort. 
  
negative.code: handle_cast({fetch_recs_async, _IsSec, _SKey, Sock, _Opts}, #state{fetchCtx=#fetchCtx{status=tailing}}=State) ->
      % io:format(user, "fetch_recs_async called in status tailing~n", []),
      imem_meta:log_to_db(warning,?MODULE,handle_cast,[{sock,Sock},{opts,_Opts},{status,tailing}],"fetch_recs_async rejected"),
      send_reply_to_client(Sock, {error,{'ClientError',"Fetching in tail mode, execute fetch_close before fetching from start again"}}),
      {noreply, State}; 
  handle_cast({fetch_recs_async, IsSec, _SKey, Sock, Opts}, #state{statement=Stmt, seco=SKey, fetchCtx=FetchCtx0}=State) ->
      % io:format(user, "fetch_recs_async called in status ~p~n", [FetchCtx0#fetchCtx.status]),
      #statement{tables=[{_Schema,Table,_Alias}|_], blockSize=BlockSize, mainSpec=MainSpec, metaFields=MetaFields} = Stmt,
      #scanSpec{sspec=SSpec0,sbinds=SBinds,fguard=FGuard,mbinds=MBinds,fbinds=FBinds,limit=Limit} = MainSpec,
      imem_meta:log_to_db(debug,?MODULE,handle_cast,[{sock,Sock},{opts,Opts},{status,FetchCtx0#fetchCtx.status}],"fetch_recs_async"),
      % io:format(user,"Table  : ~p~n", [Table]),
      % io:format(user,"SBinds : ~p~n", [SBinds]),
      % io:format(user,"MBinds : ~p~n", [MBinds]),
      % io:format(user,"FGuard : ~p~n", [FGuard]),    
      MetaRec = list_to_tuple([if_call_mfa(IsSec, meta_field_value, [SKey, N]) || N <- MetaFields]),
      % io:format(user,"MetaRec: ~p~n", [MetaRec]),
      [{SHead, SGuards0, [Result]}] = SSpec0,
      % io:format(user,"SGuards before bind : ~p~n", [SGuards0]),
      SGuards1 = case SGuards0 of
  