anchor.diff:      do_passes([{unless_flag,binary,{listing,Fun}}], St);
   do_passes([], St) -> {ok,St}.                   %Got to the end, everything ok!
   
  -%% do_macro_expand(State) -> {ok,State} | {error,State}.
  -%%  Expand macros in a file. We know about separate modules in the
  -%%  file. Everything defined before the first module is available in
  -%%  every module, after that things are local to the module in which
  -%%  they are defined. This is not really complex but we need to do it
  -%%  on one go as we need to pass on information.
  -
  -do_macro_expand(#comp{cinfo=Ci,code=Code}=St) ->
  -    case expand_pre_forms(Code, Ci) of		%Expand pre module forms
  -	{Pfs,Fs,Env0,Pws,Mst0} ->
  +%% do_split_file(State) -> {ok,State} | {error,State}.
  +%%  Split a file into separate modules.  Everything defined before the
  +%%  first module is available in every module, after that things are
  +%%  local to the module in which they are defined. We need to expand
  +%%  top-level macros in forms so we can safelt detect the start of
  +%%  each module (with define-module form).
  +
  +do_split_file(#comp{cinfo=Ci,code=Code}=St) ->
  +    case collect_forms(Code, Ci) of		%Expand pre module forms
  +	{Pfs,Fs,Env0,Mst0} ->
   	    %% Expand the modules using the pre forms and environment.
  -	    case expand_modules(Fs, Pfs, Env0, Mst0) of
  +	    case collect_modules(Fs, Pfs, Env0, Mst0) of
   		{Ms,_Mst1} ->
  -		    %%Pm = {ok,[],Pfs,Pws},
   		    {ok,St#comp{code=Ms,
  -				warnings=St#comp.warnings ++ Pws}};
  +				warnings=St#comp.warnings}};
   		{error,Es,Ws} ->
   		    {error,St#comp{code=[],     %Pseudo module list.
   				   errors=St#comp.errors ++ Es,
  
positive.code: %%                          current code will be returned.
  
  passes() ->
      [{do,fun do_macro_expand/1},
       {when_flag,to_exp,{done,fun expand_pp/1}},
  %%     {do,fun do_group_modules/1},               %Now we group modules
  %%     {when_flag,to_group,{done,fun group_pp/1}},
  %%     {do,fun do_user_macros/1},
  %%     {when_flag,to_umac,{done,fun umac_pp/1}},
       {do,fun do_lfe_pmod/1},
       {when_flag,to_pmod,{done,fun pmod_pp/1}},
       {do,fun do_lfe_lint/1},
  
negative.code:                            warnings=St#comp.warnings ++ Ws}}
      end.
  
  %% collect_forms(Forms, State) ->
  %%     {PreForms,RestForms,Env,State}.
  
  collect_forms(Fs, Ci) ->
      St0 = lfe_macro:macro_form_init(Ci),
      Env0 = lfe_env:new(),
      collect_mod_forms(Fs, Env0, St0).
  
  %% collect_modules(Forms, PreForms, PreEnv, State) ->
  %%     {Modules,State}.
  %%  Collect and expand modules upto the end. Each module initially has
  %%  the pre environment and all pre forms are appended to it.
  
  collect_modules(Fs, PreFs, PreEnv, St) ->
      collect_modules(Fs, [], PreFs, PreEnv, St).
  
  collect_modules([{['define-module',Name|_],_}=Mdef|Fs0], Ms, PreFs, PreEnv, St0) ->
      %% Expand and collect all forms upto next define-module or end.
      {Mfs0,Fs1,_,St1} = collect_mod_forms(Fs0, PreEnv, St0),
      M = {ok,Name,[Mdef] ++ PreFs ++ Mfs0,[]},
      collect_modules(Fs1, [M|Ms], PreFs, PreEnv, St1);
  collect_modules([], Ms, _PreFs, _PreEnv, St) ->
      {lists:reverse(Ms),St}.
  
  %% collect_mod_forms(Forms, Env, State) ->
  %% collect_mod_forms(Forms, Acc, Env, State) ->
  %%     {Modforms,RestForms,Env,State}.
  %%  Expand and collect forms upto the next define-module or end. We
  %%  also flatten top-level nested progn code.
  
  collect_mod_forms(Fs, Env0, St0) ->
      {Acc,Rest,Env1,St1} = collect_mod_forms(Fs, [], Env0, St0),
      {lists:reverse(Acc),Rest,Env1,St1}.
  
  collect_mod_forms([F0|Fs0], Acc, Env0, St0) ->
      case lfe_macro:macro_fileform(F0, Env0, St0) of
  	{{['define-module'|_],_}=F1,Env1,St1} ->
  	    {Acc,[F1|Fs0],Env1,St1};
  	{{['progn'|Pfs],L},Env1,St1} ->		%Flatten progn's
  	    Fs1 = [ {F,L} || F <- Pfs ] ++ Fs0,
  	    collect_mod_forms(Fs1, Acc, Env1, St1);
  	{F1,Env1,St1} ->
  	    collect_mod_forms(Fs0, [F1|Acc], Env1, St1)
      end;
  collect_mod_forms([], Acc, Env, St) -> {Acc,[],Env,St}.
  
  %% do_user_macros(State) -> {ok,State} | {error,State}.
  %% do_expand_macros(State) -> {ok,State} | {error,State}.
  %%  Process the macros in each module. Do_expand_macros is the last
  %%  pass which fully expands all remaining macros and flattens the
  %%  output.
  
  do_user_macros(#comp{cinfo=Ci,code=Ms0}=St) ->
      Umac = fun ({ok,Name,Mfs0,Ws}) ->
                     {Mfs1,_} = lfe_user_macros:module(Mfs0, Ci),
                     {ok,Name,Mfs1,Ws}
             end,
      Ms1 = lists:map(Umac, Ms0),
      {ok,St#comp{code=Ms1}}.
  
  do_expand_macros(#comp{cinfo=Ci,code=Ms0}=St) ->
      Emac = fun ({ok,Name,Fs0,Ws}) ->
  		   Env0 = lfe_env:new(),
  		   St0 = lfe_macro:expand_form_init(Ci),
  		   {Fs1,_} = lfe_lib:proc_forms(fun expand_form/3,
  						Fs0, {Env0,St0}),
  		   {ok,Name,Fs1,Ws}
  	   end,
      Ms1 = lists:map(Emac, Ms0),
      {ok,St#comp{code=Ms1}}.
  
  expand_form(F0, L, {Env0,St0}) ->
      case lfe_macro:expand_form(F0, L, Env0, St0) of
  	{[progn|Pfs],Env1,St1} ->
  	    lfe_lib:proc_forms(fun expand_form/3, Pfs, L, {Env1,St1});
  	{['eval-when-compile'|_],Env1,St1} ->
  	    {[],{Env1,St1}};
  	{F1,Env1,St1} ->
  	    {[{F1,L}],{Env1,St1}}
      end.
  
  %% do_lfe_pmod(State) -> {ok,State} | {error,State}.
  %% do_lint(State) -> {ok,State} | {error,State}.
  %% do_lfe_codegen(State) -> {ok,State} | {error,State}.
  %% do_erl_comp(State) -> {ok,State} | {error,State}.
  %%  The actual compiler passes.
  
  do_lfe_pmod(#comp{cinfo=Ci,code=Ms0}=St) ->
      Pmod = fun ({ok,_,Mfs0,Ws}) ->
  