anchor.diff:  
       [{set, McdKey, NewMcdConfig} | PerNodeKeyTouchings].
   
  -upgrade_config_from_3_0_2_to_3_0_99(Config) ->
  -    ?log_info("Upgrading config from 3.0.2 to 3.0.99"),
  -    DefaultConfig = default(),
  -    do_upgrade_config_from_3_0_2_to_3_0_99(Config, DefaultConfig).
  -
  -do_upgrade_config_from_3_0_2_to_3_0_99(Config, DefaultConfig) ->
  -    McdKey = {node, node(), memcached},
  -    JTKey = {node, node(), memcached_config},
  -    PortServersKey = {node, node(), port_servers},
  -    {value, DefaultMcdConfig} = ns_config:search([DefaultConfig], McdKey),
  -    {value, DefaultJsonTemplateConfig} = ns_config:search([DefaultConfig], JTKey),
  -    {value, DefaultPortServers} = ns_config:search([DefaultConfig], PortServersKey),
  -    {value, CurrentMcdConfig} = ns_config:search(Config, McdKey),
  -    EnginesTuple = {engines, _} = lists:keyfind(engines, 1, DefaultMcdConfig),
  -    ConfigPathTuple = {config_path, _} = lists:keyfind(config_path, 1, DefaultMcdConfig),
  -    NewMcdConfig0 = lists:keystore(engines, 1, CurrentMcdConfig, EnginesTuple),
  -    NewMcdConfig1 = lists:keystore(config_path, 1, NewMcdConfig0, ConfigPathTuple),
  -    NewMcdConfig2 = lists:keydelete(verbosity, 1, NewMcdConfig1),
  -    [{set, McdKey, NewMcdConfig2},
  -     {set, JTKey, DefaultJsonTemplateConfig},
  -     {set, PortServersKey, DefaultPortServers}].
  -
  -upgrade_config_from_3_0_99_to_4_0(Config) ->
  -    ?log_info("Upgrading config from 3.0.99 to 4.0"),
  -    do_upgrade_config_from_3_0_99_to_4_0(Config, default()).
  -
  -do_upgrade_config_from_3_0_99_to_4_0(Config, DefaultConfig) ->
  +upgrade_config_from_3_0_2_to_4_0(Config) ->
  +    ?log_info("Upgrading config from 3.0.2 to 4.0"),
  +    do_upgrade_config_from_3_0_2_to_4_0(Config, default()).
  +
  +do_upgrade_config_from_3_0_2_to_4_0(Config, DefaultConfig) ->
       MCDefaultsK = {node, node(), memcached_defaults},
       {value, NewMCDefaults} = ns_config:search([DefaultConfig], MCDefaultsK),
   
  
positive.code:                   {set, {node, _, memcached_config}, memcached_config}],
                   do_upgrade_config_from_3_0_to_3_0_2(Cfg, Default)).
  
  upgrade_3_0_2_to_3_0_99_test() ->
      Cfg = [[{some_key, some_value},
              {{node, node(), memcached},
               [{engines, old_value},
                {ssl_port, 1},
                {verbosity, 2},
                {port, 3}]},
              {{node, node(), memcached_config}, memcached_config}]],
      Default = [{{node, node(), port_servers}, port_servers_cfg},
                 {{node, node(), memcached}, [{ssl_port, 1},
                                              {config_path, cfg_path},
                                              {engines, [something]}]},
                 {{node, node(), memcached_config}, memcached_config},
                 {{node, node(), port_servers}, port_servers_cfg}],
  
      ?assertMatch([{set, {node, _, memcached}, [{engines, [something]},
                                                 {ssl_port, 1},
                                                 {port, 3},
                                                 {config_path, cfg_path}]},
                    {set, {node, _, memcached_config}, memcached_config},
                    {set, {node, _, port_servers}, port_servers_cfg}],
                   do_upgrade_config_from_3_0_2_to_3_0_99(Cfg, Default)).
  
  upgrade_3_0_99_to_4_0_test() ->
      Cfg = [[{some_key, some_value},
              {{node, node(), memcached},
               [{some_key, some_value}]},
              {{node, node(), port_servers}, old_port_servers},
              {{node, node(), memcached_config},
               {[{some_key, some_value}]}}
             ]],
      Default = [{{node, node(), memcached_defaults},
                  [{some, stuff}]},
                 {{node, node(), port_servers}, new_port_servers},
                 {{node, node(), memcached},
                  [{audit_file, audit_file_path}]},
                 {{node, node(), memcached_config},
                  {[{audit_file, audit_file}]}}],
      ?assertMatch([{set, {node, _, memcached_defaults}, [{some, stuff}]},
                    {set, {node, _, port_servers}, new_port_servers},
                    {set, {node, _, memcached}, [{some_key, some_value},
                                                 {audit_file, audit_file_path}]},
                    {set, {node, _, memcached_config}, {[{some_key, some_value},
                                                         {audit_file, audit_file}]}}],
                   do_upgrade_config_from_3_0_99_to_4_0(Cfg, Default)).
  
  no_upgrade_on_current_version_test() ->
      ?assertEqual([], upgrade_config([[{{node, node(), config_version}, get_current_version()}]])).
  
negative.code:     McdKey = {node, node(), memcached},
      {value, DefaultMcdConfig} = ns_config:search([DefaultConfig], McdKey),
      AuditFileTupleMcd = {audit_file, _} = lists:keyfind(audit_file, 1, DefaultMcdConfig),
      EnginesTuple = {engines, _} = lists:keyfind(engines, 1, DefaultMcdConfig),
      ConfigPathTuple = {config_path, _} = lists:keyfind(config_path, 1, DefaultMcdConfig),
  
      {value, CurrentMcdConfig} = ns_config:search(Config, McdKey),
      NewMcdConfig0 = lists:keystore(audit_file, 1, CurrentMcdConfig, AuditFileTupleMcd),
      NewMcdConfig1 = lists:keystore(engines, 1, NewMcdConfig0, EnginesTuple),
      NewMcdConfig2 = lists:keystore(config_path, 1, NewMcdConfig1, ConfigPathTuple),
      NewMcdConfig3 = lists:keydelete(verbosity, 1, NewMcdConfig2),
  
      JTKey = {node, node(), memcached_config},
      {value, DefaultJsonTemplateConfig} = ns_config:search([DefaultConfig], JTKey),
  
      [{set, MCDefaultsK, NewMCDefaults},
       {set, PortServersK, NewPSDefaults},
       {set, McdKey, NewMcdConfig3},
       {set, JTKey, DefaultJsonTemplateConfig}].
  
  upgrade_2_3_0_to_3_0_test() ->
      Cfg = [[{some_key, some_value},
  