anchor.diff:      WriteBufferMax = config_value(write_buffer_size_max, MergedConfig, 6 * 1024 * 1024),
       WriteBufferSize = WriteBufferMin + random:uniform(1 + WriteBufferMax - WriteBufferMin),
   
  -    %% Update the write buffer size in the merged config
  -    FinalConfig0 = orddict:store(write_buffer_size, WriteBufferSize, MergedConfig),
  -
  -    %% Make sure create_if_missing is set to true and filter out any unknown options
  -    FinalConfig = filter_allowable_options(orddict:store(create_if_missing, true, FinalConfig0)),
  -
  -    %% Open up the DB
  -    lager:debug("Opening LevelDB in ~s with options: ~p\n", [DataRoot, FinalConfig]),
  -    case eleveldb:open(DataRoot, FinalConfig) of
  +    %% Update the write buffer size in the merged config and make sure create_if_missing is set
  +    %% to true
  +    FinalConfig = orddict:store(write_buffer_size, WriteBufferSize,
  +                                orddict:store(create_if_missing, true, MergedConfig)),
  +
  +    %% Parse out the open/read/write options
  +    {OpenOpts, _BadOpenOpts} = eleveldb:validate_options(open, FinalConfig),
  +    {ReadOpts, _BadReadOpts} = eleveldb:validate_options(read, FinalConfig),
  +    {WriteOpts, _BadWriteOpts} = eleveldb:validate_options(write, FinalConfig),
  +
  +    %% Use read options for folding, but FORCE fill_cache to false
  +    FoldOpts = lists:keystore(fill_cache, 1, ReadOpts, {fill_cache, false}),
  +
  +    %% Generate a debug message with the options we'll use for each operation
  +    lager:debug("Datadir ~s options for LevelDB: ~p\n",
  +                [DataRoot, [{open, OpenOpts}, {read, ReadOpts}, {write, WriteOpts}, {fold, FoldOpts}]]),
  +    #state { data_root = DataRoot,
  +             open_opts = OpenOpts,
  +             read_opts = ReadOpts,
  +             write_opts = WriteOpts,
  +             fold_opts = FoldOpts,
  +             config = FinalConfig }.
  +
  +%% @private
  +open_db(State0) ->
  +    case eleveldb:open(State0#state.data_root, State0#state.open_opts) of
           {ok, Ref} ->
  -            {ok, Ref, FinalConfig};
  +            {ok, State0#state { ref = Ref }};
           {error, Reason} ->
               {error, Reason}
       end.
  -
  -%% @private
  -%% Remove all unknown options from a ELevelDB config
  -filter_allowable_options(Config) ->
  -    Options = [%% Base config options
  -               create_if_missing,
  -               error_if_exists,
  -               write_buffer_size,
  -               max_open_files,
  -               block_size,
  -               block_restart_interval,
  -               cache_size,
  -               paranoid_checks,
  -               compression,
  -               use_bloomfilter,
  -               verify_checksums,
  -               fill_cache,
  -               sync,
  -               %% Additional configs specific to Riak
  -               read_options,
  -               write_options,
  -               fold_options],
  -    lists:filter(fun({K, _V}) -> lists:member(K, Options) end, Config).
   
   %% @private
   config_value(Key, Config, Default) ->
  
positive.code: %% @doc Delete all objects from this eleveldb backend
  %% and return a fresh reference.
  -spec drop(state()) -> {ok, state()} | {error, term(), state()}.
  drop(#state{data_root=DataRoot}=State) ->
      case eleveldb:destroy(DataRoot, []) of
          ok ->
              case open_db(DataRoot, State#state.config) of
                  {ok, Ref, FinalConfig} ->
                      {ok, State#state { ref = Ref, config = FinalConfig }};
                  {error, Reason} ->
                      {error, Reason, State}
              end;
          {error, Reason} ->
              {error, Reason, State}
      end.
  
  %% @doc Returns true if this eleveldb backend contains any
  
negative.code: 
  -record(state, {ref :: reference(),
                  data_root :: string(),
                  open_opts = [],
                  config :: config(),
                  read_opts = [],
                  write_opts = [],
  