anchor.diff:  	    {error, T}
       end.
   
  -expand_module(Data, M, Opts) ->
  -    Imports = imports(Data, Opts),
  -    Data1 = submodules(Data, M, Opts),
  -    Data2 = expand_uses(Data1, Imports),
  +expand_module(Type, Data, M, Opts, Ps) ->
  +    OwnPfx = case Type of
  +		 module ->
  +		     {_, _, Pfx, _} = lists:keyfind(prefix,1,Data),
  +		     Pfx;
  +		 submodule ->
  +		     %% Assume that we can't expand only a submodule
  +		     [{Pfx,_,_}|_] = Ps,
  +		     Pfx
  +	     end,
  +    Imports = imports(Data, Opts, Ps),
  +    Data1 = submodules(Data, OwnPfx, M, Opts, Ps),
  +    Data2 = expand_uses(Data1, OwnPfx, Imports, Ps),
       Typedefs = [{T, lists:keyfind(type,1,Def)} ||
   		   {typedef, _, T, Def} <- Data2],
  -    Data3 = expand_elems_(Data2, M, Typedefs, Imports),
  +    ModRec = #mod{prefix = OwnPfx,
  +		  module = M,
  +		  typedefs = Typedefs,
  +		  imports = Imports,
  +		  data = Data2},
  +    Data3 = expand_elems_(Data2, ModRec),
       {Data3, Typedefs}.
   
  -imports(Data, Opts) ->
  +imports(Data, Opts, Ps) ->
       lists:foldl(
         fun({import,L,M,IOpts}, Dict) ->
  -	      try import_(M, IOpts, Opts, L, Dict)
  +	      try import_(M, IOpts, Opts, L, Ps, Dict)
   	      catch
   		  {error, E} ->
   		      throw({E, [import, L, M]})
  
positive.code: 
  -include("../include/yang_types.hrl").
  
  %-define(debug, true).
  
  -ifdef(debug).
  
negative.code: 		      true ->
  			  error({include_loop, {L, [SubM|Visited]}});
  		      false ->
  			  Data1 = include_submodule(SubM, IOpts, Opts,
  						    [{Pfx,M,Opts}|Ps]),
  			  {Data1, [SubM|Visited]}
  		  end;
  	     (Other, Acc) ->
  