anchor.diff:          ?assertEqual(ok, imem_meta:check_table(skvhTEST)),        
           ?assertEqual(ok, imem_meta:check_table(skvhAuditTEST_86400@)),
   
  -        ?assertEqual({ok,[1296644,124793159,117221887]}, write(Channel, <<"[1,a]",9,"123456",10,"[1,b]",9,"234567",13,10,"[1,c]",9,"345678">>)),
  +        ?assertEqual({ok,[<<"1296644">>,<<"124793159">>,<<"117221887">>]}, write(Channel, <<"[1,a]",9,"123456",10,"[1,b]",9,"234567",13,10,"[1,c]",9,"345678">>)),
   
           ?assertEqual({ok,[KVa]}, read(Channel, <<"[1,a]">>)),
           ?assertEqual({ok,[KVc]}, read(Channel, <<"[1,c]">>)),
  
positive.code: 	{L,true} = imem_meta:select(TN, [MatchFunction]),
  	delete(Cmd, {TN,AN}, L, []).
  
  
  readGT(_Channel, _Item, _CKey1, _Limit) ->
  	ok.
  
  delete(Channel, KeyTable) when is_binary(Channel), is_binary(KeyTable) -> 
  	Cmd = [delete,Channel,KeyTable],
  	delete(Cmd, create_check_channel(Channel), key_table_to_term_list(KeyTable), []).
  
  delete(Cmd, _, [], Acc)  -> return_list(Cmd, lists:reverse(Acc));
  delete(Cmd, {TN,AN}, [Key|Keys], Acc)  ->
  	Hash = case imem_meta:read(TN,Key) of
  		[] ->						undefined;
  		[#skvhTable{chash=H}] ->	H
  	end,
  	imem_meta:delete(TN,Key),									%% ToDo: wrap in transaction
  	imem_meta:write(AN,#skvhAudit{time=erlang:now(),ckey=Key}),	%% ToDo: wrap in transaction
  	delete(Cmd, {TN,AN}, Keys, [Hash|Acc]).
  
  deleteGELT(Channel, CKey1, CKey2) when is_binary(Channel), is_binary(CKey1), is_binary(CKey2) ->
  	Cmd = [deleteGELT, Channel, CKey1, CKey2],
  	deleteGELT(Cmd, create_check_channel(Channel), key_to_term(CKey1), key_to_term(CKey2)).
  
  deleteGELT(Cmd, {TN,AN}, Key1, Key2) ->
  	MatchHead = {skvhTable, '$1', '$2', '$3'},
  	MatchFunction = {MatchHead, [{'>=', '$1', Key1}, {'<', '$1', Key2}], ['$1']},
  	{L,true} = imem_meta:select(TN, [MatchFunction]),
  	delete(Cmd, {TN,AN}, L, []).
  
  deleteGTLT(Channel, CKey1, CKey2) when is_binary(Channel), is_binary(CKey1), is_binary(CKey2) ->
  	Cmd = [deleteGTLT, Channel, CKey1, CKey2],
  	deleteGTLT(Cmd, create_check_channel(Channel), key_to_term(CKey1), key_to_term(CKey2)).
  
  deleteGTLT(Cmd, {TN,AN}, Key1, Key2) ->
  	MatchHead = {skvhTable, '$1', '$2', '$3'},
  
negative.code: 		_ ->	binary:replace(Bin, <<13>>, <<>>, [global])
  	end.
  
  io_key_to_term(Key) when is_binary(Key) ->
  	imem_datatype:io_to_term(Key).
  
  term_key_to_io(Key) ->
  	imem_datatype:term_to_io(Key).
  
  % io_hash_to_term(Hash) when is_binary(Hash) -> Hash.
  
  term_hash_to_io(Hash) when is_binary(Hash) -> 
  	Hash; 
  term_hash_to_io(Hash) when is_integer(Hash) -> 
  	list_to_binary(integer_to_list(Hash)).
  
  io_value_to_term(V) ->
  	% imem_datatype:io_to_term(V).
  	V.
  
  term_value_to_io(V) ->
  	% imem_datatype:term_to_io(V).
  	V.
  
  io_key_table_to_term_list(KeyTable) ->
  	BList = binary:split(clean_table(KeyTable),<<10>>,[global]),	%% split at line feed positions
  	[io_key_to_term(Key) || Key <- BList].
  
  io_kv_pair_to_tuple(KVPair) ->
  	case binary:split(KVPair,<<9>>,[global]) of			%% split at tab position
  		[K,V] -> 	{io_key_to_term(K),io_value_to_term(V)};
  		_ ->		?ClientError(?E102)
  	end.
  
  term_kv_tuple_to_io({K,V}) ->
  	KeyBin = term_key_to_io(K),
  	ValueBin = term_value_to_io(V), 
  	<<KeyBin/binary,9,ValueBin/binary>>.
  
  term_kh_tuple_to_io({K,H}) ->
  	KeyBin = term_key_to_io(K),
  	HashBin = term_hash_to_io(H), 
  	<<KeyBin/binary,9,HashBin/binary>>.
  
  io_kv_table_to_tuple_list(KVTable) ->
  	BList = binary:split(clean_table(KVTable),<<10>>,[global]),		%% split at line feed positions
  	[io_kv_pair_to_tuple(KVbin) || KVbin <- BList].
  
  read(Channel, KeyTable) when is_binary(Channel), is_binary(KeyTable) ->
  	Cmd = [read,Channel,KeyTable],
  	read(Cmd, create_check_channel(Channel), io_key_table_to_term_list(KeyTable), []).
  
  read(Cmd, _, [], Acc)  -> return_list(Cmd, lists:reverse(Acc));
  read(Cmd, {TN,AN}, [Key|Keys], Acc)  ->
  	KVP = case imem_meta:read(TN,Key) of
  		[] ->								term_kv_tuple_to_io({Key,<<"undefined">>});
  		[#skvhTable{ckey=K,cvalue=V}] ->	term_kv_tuple_to_io({K,V})
  	end,
  	read(Cmd, {TN,AN}, Keys, [KVP|Acc]).
  	
  
  write(Channel, KVTable) when is_binary(Channel), is_binary(KVTable) ->
  	Cmd = [write,Channel,KVTable],
  	write(Cmd, create_check_channel(Channel), io_kv_table_to_tuple_list(KVTable), []).
  
  write(Cmd, _, [], Acc)  -> return_list(Cmd, lists:reverse(Acc));
  write(Cmd, {TN,AN}, [{K,V}|KVPairs], Acc)  ->
  	Hash = list_to_binary(integer_to_list(erlang:phash2({K,V}))),
  	imem_meta:write(TN,#skvhTable{ckey=K,cvalue=V,chash=Hash}),			%% ToDo: wrap in transaction
  	imem_meta:write(AN,#skvhAudit{time=erlang:now(),ckey=K,cvalue=V}),	%% ToDo: wrap in transaction
  	write(Cmd, {TN,AN}, KVPairs, [Hash|Acc]).
  
  readGELT(Channel, Item, CKey1, CKey2) when is_binary(Item), is_binary(CKey1), is_binary(CKey2) ->
  	Cmd = [readGELT, Channel, Item, CKey1, CKey2],
  	readGELT(Cmd, create_check_channel(Channel), Item, io_key_to_term(CKey1), io_key_to_term(CKey2)).
  
  readGELT(Cmd, {TN,_}, Item, Key1, Key2) ->
  	MatchHead = {skvhTable, '$1', '$2', '$3'},
  	MatchFunction = {MatchHead, [{'>=', '$1', Key1}, {'<', '$1', Key2}], ['$_']},
  	{L,true} = imem_meta:select(TN, [MatchFunction]),
  	project_result(Cmd, L, Item).
  
  project_result(Cmd, L, <<"key">>) ->
  	return_list(Cmd, [term_key_to_io(K) ||  #skvhTable{ckey=K} <- L]);
  project_result(Cmd, L, <<"value">>) ->
  	return_list(Cmd, [term_value_to_io(V) ||  #skvhTable{cvalue=V} <- L]);
  project_result(Cmd, L, <<"hash">>) ->
  	return_list(Cmd, [term_hash_to_io(H) ||  #skvhTable{chash=H} <- L]);
  project_result(Cmd, L, <<"kvpair">>) ->
  	return_list(Cmd, [term_kv_tuple_to_io({K,V}) ||  #skvhTable{ckey=K,cvalue=V} <- L]);
  project_result(Cmd, L, <<"khpair">>) ->
  	return_list(Cmd, [term_kh_tuple_to_io({K,H}) ||  #skvhTable{ckey=K,chash=H} <- L]).
  
  readGT(Channel, Item, CKey1, Limit)  when is_binary(Item), is_binary(CKey1), is_binary(Limit) ->
  	Cmd = [readGT, Channel, Item, CKey1, Limit],
  	readGT(Cmd, create_check_channel(Channel), Item, io_key_to_term(CKey1), io_key_to_term(Limit)).
  
  readGT(Cmd, {TN,_}, Item, Key1, Limit) ->
  	MatchHead = {skvhTable, '$1', '$2', '$3'},
  	MatchFunction = {MatchHead, [{'>', '$1', Key1}], ['$_']},
  	{L,_} = imem_meta:select(TN, [MatchFunction], Limit),
  	project_result(Cmd, L, Item).
  
  delete(Channel, KeyTable) when is_binary(Channel), is_binary(KeyTable) -> 
  	Cmd = [delete,Channel,KeyTable],
  	delete(Cmd, create_check_channel(Channel), io_key_table_to_term_list(KeyTable), []).
  
  delete(Cmd, _, [], Acc)  -> return_list(Cmd, lists:reverse(Acc));
  delete(Cmd, {TN,AN}, [Key|Keys], Acc)  ->
  	Hash = case imem_meta:read(TN,Key) of
  		[] ->						<<"undefined">>;
  		[#skvhTable{chash=H}] ->	H
  	end,
  	imem_meta:delete(TN,Key),									%% ToDo: wrap in transaction
  	imem_meta:write(AN,#skvhAudit{time=erlang:now(),ckey=Key}),	%% ToDo: wrap in transaction
  	delete(Cmd, {TN,AN}, Keys, [Hash|Acc]).
  
  deleteGELT(Channel, CKey1, CKey2) when is_binary(Channel), is_binary(CKey1), is_binary(CKey2) ->
  	Cmd = [deleteGELT, Channel, CKey1, CKey2],
  	deleteGELT(Cmd, create_check_channel(Channel), io_key_to_term(CKey1), io_key_to_term(CKey2)).
  
  deleteGELT(Cmd, {TN,AN}, Key1, Key2) ->
  	MatchHead = {skvhTable, '$1', '$2', '$3'},
  