anchor.diff:      Parts = make_splits(Time, Count, S, []),
       CurFiles = chash:lookup(Idx, CHash),
       Parts1 = [{B, round(C*?DATA_SIZE)} || {B, C} <- Parts],
  -    case do_put(MSet#mset{dir=[D, $/, integer_to_list(Idx)]}, Metric, Parts1, Value, CurFiles) of
  +    MSet1 = case gb_sets:is_element(Metric, Ms) of
  +                true ->
  +                    MSet;
  +                false ->
  +                    MSetx = MSet#mset{metrics=gb_sets:add_element(Metric, Ms)},
  +                    save_set(MSetx),
  +                    MSetx
  +            end,
  +    case do_put(MSet1#mset{dir=[D, $/, integer_to_list(Idx)]}, Metric, Parts1, Value, CurFiles) of
           CurFiles1 when CurFiles1 =:= CurFiles ->
  -            MSet;
  +            MSet1;
           CurFiles1 ->
               CHash1 = chash:update(Idx, CurFiles1, CHash),
  -            MSet#mset{chash = CHash1}
  +            MSet1#mset{chash = CHash1}
       end;
   
   
  
positive.code: 
  -record(mstore, {name, file, offset, size, index=gb_trees:empty(), next=0}).
  
  -record(mset, {size, chash, dir, seed}).
  -define(DATA_SIZE, 8).
  -define(OPTS, [raw, binary]).
  -export([put/4, get/4, new/3, close/1, open/1, open/3, avg/3,
           sum/3, max/3, min/3, to_list/1]).
  
  
  %% @doc Opens an existing mstore.
  
negative.code: 
  open(Dir) ->
      case file:consult([Dir | "/mstore"]) of
          {ok, [{FileSize, NumFiles, Seed, Metrics}]} ->
              {ok, #mset{size=FileSize, chash=chash:fresh(NumFiles, []), dir=Dir, seed=Seed, metrics=gb_sets:from_list(Metrics)}};
          _ ->
              {error, not_found}
      end.
  