anchor.diff:              %% probably crashed and this is a restart.
               ok
       end,
  -    gen_server:start_link({local, Name}, ?MODULE, [Name], []).
  -
  -%% @private
  -init([Name]) ->
  -  {ok, #state{name=Name}}.
  -
  -%% @private
  -handle_call({remove_resource, Resource}, _From, State=#state{name=Name}) ->
  +    gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
  +
  +%% @private
  +init([]) ->
  +    {ok, undefined}.
  +
  +%% @private
  +handle_call({remove_resource, Name, Resource}, _From, State) ->
       DL = filter_by_resource(Resource, get_dispatch_list(Name)),
       {reply, set_dispatch_list(Name, DL), State};
   
  -handle_call({remove_route, Route}, _From, State=#state{name=Name}) ->
  +handle_call({remove_route, Name, Route}, _From, State) ->
       DL = [D || D <- get_dispatch_list(Name),
                  D /= Route],
       {reply, set_dispatch_list(Name, DL), State};
   
  -handle_call({add_route, Route}, _From, State=#state{name=Name}) ->
  +handle_call({add_route, Name, Route}, _From, State) ->
       DL = [Route|[D || D <- get_dispatch_list(Name),
                         D /= Route]],
       {reply, set_dispatch_list(Name, DL), State};
   
  -handle_call({init_routes, DefaultRoutes}, _From, State=#state{name=Name}) ->
  +handle_call({init_routes, Name, DefaultRoutes}, _From, State) ->
       %% if the table lacks a dispatch_list row, set it
  -    ets:insert_new(Name, {dispatch_list, DefaultRoutes}),
  +    ets:insert_new(?MODULE, {Name, DefaultRoutes}),
       {reply, ok, State};
   
   handle_call(_Request, _From, State) ->
  
positive.code: % arguments to the resource module handling the matching request.
  
  -define(SERVER, ?MODULE).
  
  -record(state, {name :: atom()}).
  
  %% @spec add_route(hostmatchterm() | pathmatchterm()) -> ok
  %% @doc Adds a route to webmachine's route table. The route should
  %%      be the format documented here:
  %% http://bitbucket.org/justin/webmachine/wiki/DispatchConfiguration
  add_route(Route) ->
      add_route(?SERVER, Route).
  
  add_route(Name, Route) ->
      gen_server:call(Name, {add_route, Route}, infinity).
  
  %% @spec remove_route(hostmatchterm() | pathmatchterm()) -> ok
  %% @doc Removes a route from webamchine's route table. The route
  %%      route must be properly formatted
  %% @see add_route/2
  remove_route(Route) ->
      remove_route(?SERVER, Route).
  
  remove_route(Name, Route) ->
      gen_server:call(Name, {remove_route, Route}, infinity).
  
  %% @spec remove_resource(atom()) -> ok
  %% @doc Removes all routes for a specific resource module.
  remove_resource(Resource) when is_atom(Resource) ->
      remove_resource(?SERVER, Resource).
  
  remove_resource(Name, Resource) when is_atom(Resource) ->
      gen_server:call(Name, {remove_resource, Resource}, infinity).
  
  %% @spec get_routes() -> [{[], res, []}]
  %% @doc Retrieve a list of routes and resources set in webmachine's
  %%      route table.
  get_routes() ->
      get_routes(?MODULE).
  
  get_routes(Name) ->
      get_dispatch_list(Name).
  
negative.code: %% @spec init_routes() -> ok
  %% @doc Set the default routes, unless the routing table isn't empty.
  init_routes(DefaultRoutes) ->
      init_routes(?DEFAULT, DefaultRoutes).
  
  init_routes(Name, DefaultRoutes) ->
      gen_server:call(?SERVER, {init_routes, Name, DefaultRoutes}, infinity).
  
  %% @spec start_link() -> {ok, pid()} | {error, any()}
  %% @doc Starts the webmachine_router gen_server.
  start_link() ->
      %% We expect to only be called from webmachine_sup
      %%
      %% Set up the ETS configuration table.
      try ets:new(?MODULE, [named_table, public, set, {keypos, 1},
                  {read_concurrency, true}]) of
          _Result ->
              ok
  