anchor.diff:  allocate({[], Allocated}, _Pid) ->
     {{[], Allocated}, {error, no_frequency}};
   allocate({[Freq|Free], Allocated}, Pid) ->
  -  link(Pid),                                               %%% ADDED
  +  link(Pid),
     {{Free, [{Freq, Pid}|Allocated]}, {ok, Freq}}.
   
  -deallocate({Free, Allocated}, Freq) ->
  -  {value,{Freq,Pid}} = lists:keysearch(Freq,1,Allocated),  %%% ADDED
  -  unlink(Pid),                                             %%% ADDED
  -  NewAllocated=lists:keydelete(Freq, 1, Allocated),
  -  {[Freq|Free],  NewAllocated}.
  +deallocate({Free, Allocated}=F, Freq) ->
  +  Val = lists:keysearch(Freq,1,Allocated),
  +  case Val of
  +      {value,{Freq,Pid}} ->
  +	  unlink(Pid),
  +	  NewAllocated=lists:keydelete(Freq, 1, Allocated),
  +	  {{[Freq|Free],  NewAllocated}, {ok}};
  +      false ->
  +	  {F, {error, not_allocated}}
  +  end.
   
   exited({Free, Allocated}, Pid) ->                %%% FUNCTION ADDED
       case lists:keysearch(Pid,2,Allocated) of
  
positive.code:     spawn(?MODULE,supervisor_init,[]).
  
  start() ->
      register(frequency,
  	     spawn_link(frequency, init, [])).
  
  init() ->
    process_flag(trap_exit, true),    %%% ADDED
  
negative.code: %% The Main Loop
  
  loop(Frequencies) ->
      receive
  	{request, Pid, allocate} ->
  	    {NewFrequencies, Reply} = allocate(Frequencies, Pid),
  	    Pid ! {reply, Reply},
  	    loop(NewFrequencies);
  	{request, Pid , {deallocate, Freq}} ->
  	    {NewFrequencies, Reply} = deallocate(Frequencies, Freq),
  	    Pid ! {reply, Reply},
  	    loop(NewFrequencies);
  	{request, Pid, stop} ->
  	    Pid ! {reply, stopped};
  	{'EXIT', Pid, _Reason} ->                   %%% CLAUSE ADDED
  	    NewFrequencies = exited(Frequencies, Pid),
  	    loop(NewFrequencies)
      end.
  
  %% Functional interface
  
  allocate() ->
      ?MODULE ! {request, self(), allocate},
      receive
  	    {reply, Reply} -> Reply
      end.
  
  deallocate(Freq) ->
      ?MODULE ! {request, self(), {deallocate, Freq}},
      receive
  	    {reply, Reply} -> Reply
      end.
  
  stop() ->
      ?MODULE ! {request, self(), stop},
      receive
  	    {reply, Reply} -> Reply
      end.
  