anchor.diff:  	    {error, Reason}
       end.
   
  +%% Open the given archive and iterate through all files with an own
  +%% wrapper fun in order to identify each file as a component list as
  +%% returned from path_split/1.
  +%%
  +%% In the archive (zip) file, directory elements might or might not be
  +%% present. To ensure consistency, a directory element is added if it
  +%% does not already exist (ensure_virual_dir/6). NOTE that there will
  +%% be no such directory element for the top directory of the archive.
   open_archive(Archive, FileInfo, Acc, Fun) ->
       FakeFI = FileInfo#file_info{type = directory},
       Wrapper =
  -	fun({N, GI, GB}, {A, I, FunnyDirs}) -> % Full iteration at open
  -		Funny = funny_split(N, $/),
  -		FunnyDirs2 =
  -		    case Funny of
  -			["" | FunnyDir] ->
  -			    [FunnyDir | FunnyDirs];
  +	fun({N, GI, GB}, {A, I, Dirs}) ->
  +		Components = path_split(N),
  +		Dirs2 =
  +		    case Components of
  +			["" | Dir] ->
  +			    %% This is a directory
  +			    [Dir | Dirs];
   			_ ->
  -			    FunnyDirs
  +			    %% This is a regular file
  +			    Dirs
   		    end,
  -		{Includes, FunnyDirs3, A2} = 
  -		    ensure_virtual_dirs(Funny, Fun, FakeFI, [{true, Funny}], FunnyDirs2, A),
  -		{_Continue, A3} = Fun({Funny, GI, GB}, A2),
  -		{true, Includes, {A3, I, FunnyDirs3}}
  +		{Includes, Dirs3, A2} =
  +		    ensure_virtual_dirs(Components, Fun, FakeFI,
  +					[{true, Components}], Dirs2, A),
  +		{_Continue, A3} = Fun({Components, GI, GB}, A2),
  +		{true, Includes, {A3, I, Dirs3}}
   	end,
       prim_zip:open(Wrapper, {Acc, FakeFI, []}, Archive).
   
  -ensure_virtual_dirs(Funny, Fun, FakeFI, Includes, FunnyDirs, Acc) ->
  -    case Funny of
  +ensure_virtual_dirs(Components, Fun, FakeFI, Includes, Dirs, Acc) ->
  +    case Components of
   	[_] ->
  -	    {Includes, FunnyDirs, Acc};
  -	[_ | FunnyDir] ->
  -	    case lists:member(FunnyDir, FunnyDirs) of % BIF
  +	    %% Don't add virtual dir for top directory
  +	    {Includes, Dirs, Acc};
  +	[_ | Dir] ->
  +	    case lists:member(Dir, Dirs) of % BIF
   		false ->
  +		    %% The directory does not yet exist - add it
   		    GetInfo = fun() -> FakeFI end,
   		    GetBin = fun() -> <<>> end,
  -		    VirtualDir = ["" | FunnyDir],
  +		    VirtualDir = ["" | Dir],
   		    Includes2 = [{true, VirtualDir, GetInfo, GetBin} | Includes],
  -		    FunnyDirs2 = [FunnyDir | FunnyDirs],
  -		    {I, F, Acc2} = ensure_virtual_dirs(FunnyDir, Fun, FakeFI, Includes2, FunnyDirs2, Acc),
  +		    Dirs2 = [Dir | Dirs],
  +
  +		    %% Recursively ensure dir elements on all levels
  +		    {I, F, Acc2} = ensure_virtual_dirs(Dir, Fun, FakeFI,
  +						       Includes2, Dirs2, Acc),
  +
   		    {_Continue, Acc3} = Fun({VirtualDir, GetInfo, GetBin}, Acc2),
   		    {I, F, Acc3};
   		true ->
  -		    ensure_virtual_dirs(FunnyDir,Fun,FakeFI,Includes,FunnyDirs,Acc)
  +		    %% The directory element does already exist
  +		    %% Recursivly ensure dir elements on all levels
  +		    ensure_virtual_dirs(Dir,Fun,FakeFI,Includes,Dirs,Acc)
   	    end
  -   end.
  +    end.
   
   foldl_archive(PrimZip, Acc, Fun) ->
       Wrapper =
  -        fun({Funny, GI, GB}, A) ->
  +        fun({Components, GI, GB}, A) ->
                   %% Allow partial iteration at foldl
  -                {Continue, A2} = Fun({Funny, GI, GB}, A),
  +                {Continue, A2} = Fun({Components, GI, GB}, A),
                   {Continue, true, A2}
           end,                        
       prim_zip:foldl(Wrapper, Acc, PrimZip).
  
positive.code:         case PS#prim_state.primary_archive of
              undefined ->
                  Fun =
                      fun({Funny, _GI, _GB}, A) ->
                              case Funny of
                                  ["", "nibe", RevApp] -> % Reverse ebin
                                      %% Collect ebin directories in archive
                                      Ebin = reverse(RevApp) ++ "/ebin",
  
negative.code:                 end;
              {archive, ArchiveFile, FileInArchive} ->
                  debug(PS, {archive_read_file_info, File}),
                  FileComponents = path_split(FileInArchive),
                  Fun =
                      fun({Components, GetInfo, _GetBin}, Acc)  ->
  			    case Components of
  				["" | F] when F =:= FileComponents ->
                                      %% Directory
                                      {false, {ok, GetInfo()}};
                                  F when F =:= FileComponents ->
                                      %% Plain file
                                      {false, {ok, GetInfo()}};
                                  _ ->
  