anchor.diff:              file:delete(erlcinfo_file(Dir))
       end,
       Dirs = source_and_include_dirs(InclDirs, Erls),
  -    Modified = lists:foldl(update_erlcinfo_fun(G, Dirs), false, Erls),
  -    if Modified -> store_erlcinfo(G, InclDirs, Dir); not Modified -> ok end,
  +    %% A source file may have been renamed or deleted. Remove it from the graph
  +    %% and remove any beam file for that source if it exists.
  +    Modified = maybe_rm_beams_and_edges(G, OutDir, Erls),
  +    Modified1 = lists:foldl(update_erlcinfo_fun(G, Dirs), Modified, Erls),
  +    if Modified1 -> store_erlcinfo(G, InclDirs, Dir); not Modified1 -> ok end,
       G.
  +
  +maybe_rm_beams_and_edges(G, Dir, Files) ->
  +    Vertices = digraph:vertices(G),
  +    case lists:filter(fun(File) ->
  +                              case filename:extension(File) =:= ".erl" of
  +                                  true ->
  +                                      maybe_rm_beam_and_edge(G, Dir, File);
  +                                  false ->
  +                                      false
  +                              end
  +                      end, lists:sort(Vertices) -- lists:sort(Files)) of
  +        [] ->
  +            false;
  +        _ ->
  +            true
  +    end.
   
   source_and_include_dirs(InclDirs, Erls) ->
       SourceDirs = lists:map(fun filename:dirname/1, Erls),
  
positive.code: %% parse transforms, behaviours etc.) located in their directories or given
  %% InclDirs. Note that last modification times stored in vertices already respect
  %% dependencies induced by given graph G.
  init_erlcinfo(InclDirs, Erls, Dir) ->
      G = digraph:new([acyclic]),
      try restore_erlcinfo(G, InclDirs, Dir)
      catch
  
negative.code:     case filelib:is_regular(Source) of
          true ->
              %% Actually exists, don't delete
              false;
          false ->
              Target = target_base(OutDir, Source) ++ ".beam",
              ?DEBUG("Source ~s is gone, deleting previous beam file if it exists ~s", [Source, Target]),
              file:delete(Target),
              digraph:del_vertex(G, Source),
              true
      end.
  
  opts_changed(NewOpts, Target) ->
  