[Bug 301785]
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlatVirtualComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlatVirtualComponent.java
index 5767878..45d7be5 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlatVirtualComponent.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/FlatVirtualComponent.java
@@ -32,10 +32,34 @@
 			private static final long serialVersionUID = 1L;
 	}
 	
+	/**
+	 * The datamodel, which may contain preferences, settings, or other data
+	 * used by the various participants to determine how to properly 
+	 * traverse this component. 
+	 */
 	private FlatComponentTaskModel dataModel;
+	
+	/**
+	 * The root component being flattened. 
+	 */
 	private IVirtualComponent component;
+	
+	/**
+	 * The list of participants to engage in the flattening process. 
+	 */
 	private IFlattenParticipant[] participants;
 
+	/**
+	 * The list of member resources for this component
+	 */
+	private List<IFlatResource> members = null;
+	
+	/**
+	 * The list of child modules for this component
+	 */
+	private List<IChildModuleReference> children = null;
+	
+	
 	public FlatVirtualComponent(IVirtualComponent component) {
 		this(component, new FlatComponentTaskModel());
 	}
@@ -47,9 +71,9 @@
 		dataModel.put(EXPORT_MODEL, this);
 	}
 	
-	/*
-	 * Kinda ugly but functional and allows the option
-	 * to be set as one or a list for convenience
+	/**
+	 * Set the list of participants for this virtual component. 
+	 * This is pulled from the datamodel. 
 	 */
 	protected IFlattenParticipant[] setParticipants() {
 		Object o = dataModel.get(PARTICIPANT_LIST);
@@ -67,14 +91,20 @@
 		return new IFlattenParticipant[]{};
 	}
 	
-	private List<IFlatResource> members = null;
-	private List<IChildModuleReference> children = null;
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent#fetchResources()
+	 */
 	public IFlatResource[] fetchResources() throws CoreException {
 		if( members == null)
 			cacheResources();
 		return (FlatResource[]) members.toArray(new FlatResource[members.size()]);
 	}
 	
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent#getChildModules()
+	 */
 	public IChildModuleReference[] getChildModules() throws CoreException {
 		if( members == null )
 			cacheResources();
@@ -134,15 +164,24 @@
 			//addRelevantOutputFolders(); // to be done in a participant later
 
 			addConsumedReferences(util, component, new Path(""));
-			addUsedReferences(component, new Path(""));
+			addUsedReferences(util, component, new Path(""));
 		}
 	}
 	
 	/**
 	 * Consumed references are, by definition, consumed, and should not
 	 * be eligible to be exposed as child modules. They are consumed 
-	 * directly into the module tree
+	 * directly into the module tree. 
 	 * 
+	 * The reference in question may have references of its own, both
+	 * used and consumed. References of the child will be treated
+	 * as references of the parent, whether consumed or used.  
+	 * 
+	 * A key difference in the handling of non-child USED references 
+	 * as compared to CONSUMES is that CONSUMED references have their
+	 * archiveName *ignored*, and its child members are directly consumed. 
+	 * In contrast, a USED non-child keeps its archiveName as the folder name. 
+	 *  
 	 * @param vc
 	 */
 	protected void addConsumedReferences(VirtualComponentFlattenUtility util, IVirtualComponent vc, IPath root) throws CoreException {
@@ -156,15 +195,15 @@
 					IVirtualFolder vFolder = consumedComponent.getRootFolder();
 					util.addMembers(consumedComponent, vFolder, root.append(reference.getRuntimePath().makeRelative()));
 					addConsumedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative()));
-					addUsedReferences(consumedComponent, root.append(reference.getRuntimePath().makeRelative()));
+					addUsedReferences(util, consumedComponent, root.append(reference.getRuntimePath().makeRelative()));
 				}
     		}
     	}
 	}
 	
 	/**
-	 * This checks to see if any exportable file is actually a child module,
-	 * which should be exposed differently
+	 * This checks to see if any exportable file is actually a child module.
+	 * Children modules will be exposed via the getChildModules() method. 
 	 */
 	public boolean shouldAddComponentFile(IVirtualComponent current, IFlatFile file) {
 		for( int i = 0; i < participants.length; i++ ) {
@@ -178,7 +217,7 @@
 		return true;
 	}
 
-	protected void addUsedReferences(IVirtualComponent vc, IPath root) {
+	protected void addUsedReferences(VirtualComponentFlattenUtility util, IVirtualComponent vc, IPath root) throws CoreException {
 		IVirtualReference[] allReferences = vc.getReferences();
     	for (int i = 0; i < allReferences.length; i++) {
     		IVirtualReference reference = allReferences[i];
@@ -188,7 +227,7 @@
 					continue;
 				
 				if( !isChildModule(reference)) {
-					addNonChildUsedReference(vc, reference, root.append(reference.getRuntimePath()));
+					addNonChildUsedReference(util, vc, reference, root.append(reference.getRuntimePath()));
 				} else {
 					boolean duplicate = false;
 					ChildModuleReference cm = new ChildModuleReference(reference, root);
@@ -225,58 +264,69 @@
 		return false;
 	}
 
-	protected void addNonChildUsedReference(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath) {
-		FlatFile mf = null;
-		final String archiveName = reference.getArchiveName();
-		final IVirtualComponent virtualComp = reference.getReferencedComponent();
-		
-		// Binary used references must be added as a single file unless they're child modules
-		if( virtualComp.isBinary()) {
-			IFile ifile = (IFile)virtualComp.getAdapter(IFile.class);
-			if( ifile != null ) {
-				String name = null != archiveName ? archiveName : ifile.getName();
-				mf = new FlatFile(ifile, name, runtimePath.makeRelative());
-			} else {
-				File extFile = (File)virtualComp.getAdapter(File.class);
-				if( extFile != null ) {
-					String name = null != archiveName ? archiveName : extFile.getName();
-					mf = new FlatFile(extFile, name, runtimePath.makeRelative());
-				}
-			}
-			
-			if( mf != null ) {
-				IFlatResource moduleParent = VirtualComponentFlattenUtility.getExistingModuleResource(members, mf.getModuleRelativePath());
-				if (moduleParent != null && moduleParent instanceof FlatFolder) {
-					VirtualComponentFlattenUtility.addMembersToModuleFolder((FlatFolder)moduleParent, new FlatResource[]{mf});
-				} else {
-					if( shouldAddComponentFile(virtualComp, mf)) {
-						if (mf.getModuleRelativePath().isEmpty()) {
-							for( IFlatResource tmp : members) 
-								if( tmp.getName().equals(mf.getName()))
-									return;
-							members.add(mf);
-						} else {
-							if (moduleParent == null) {
-								moduleParent = VirtualComponentFlattenUtility.ensureParentExists(members, mf.getModuleRelativePath(), (IContainer)parent.getRootFolder().getUnderlyingResource());
-							}
-							VirtualComponentFlattenUtility.addMembersToModuleFolder((FlatFolder)moduleParent, new FlatResource[] {mf});
-						}
-					} else {
-						// Automatically added to children if it needed to be
-					}
-				}
-			}
+	protected void addNonChildUsedReference(VirtualComponentFlattenUtility util, IVirtualComponent parent, 
+			IVirtualReference reference, IPath runtimePath) throws CoreException {
+		if( reference.getReferencedComponent().isBinary()) {
+			handleNonChildUsedBinaryReference(util, parent, reference, runtimePath);
 		} else /* !virtualComp.isBinary() */ {
 			/*
 			 * used references to non-binary components that are NOT child modules.
 			 * These should be 'consumed' but maintain their name
-			 * As of now I don't believe there are any such instances of this and this can be delayed
-			 * I also believe in most cases, this probably is a child module that the parent just doesn't know about.
-			 * Example: Ear Project consumes ESB project, Ear project does not recognize ESB project
+			 * As of now I don't believe there are any such instances of this.
+			 * I also believe in most cases, this probably is a child module that 
+			 * the parent just doesn't know about.
+			 * 
+			 * Example: Ear Project consumes ESB project, Ear project does not 
+			 * recognize ESB project as a child However, if the server adapter 
+			 * can use nested exploded deployments (folders instead of zips),
+			 * then this will still work. 
 			 * 
 			 * TODO Investigate / Discuss
 			 */
+			util.addMembers(reference.getReferencedComponent(), reference.getReferencedComponent().getRootFolder(), 
+					runtimePath.append(reference.getArchiveName()));
 		}
-
+	}
+	
+	protected void handleNonChildUsedBinaryReference(VirtualComponentFlattenUtility util, IVirtualComponent parent, 
+			IVirtualReference reference, IPath runtimePath) throws CoreException {
+		// Binary used references must be added as a single file unless they're child modules
+		final String archiveName = reference.getArchiveName();
+		final IVirtualComponent virtualComp = reference.getReferencedComponent();
+		FlatFile mf = null;
+		IFile ifile = (IFile)virtualComp.getAdapter(IFile.class);
+		if( ifile != null ) {
+			String name = null != archiveName ? archiveName : ifile.getName();
+			mf = new FlatFile(ifile, name, runtimePath.makeRelative());
+		} else {
+			File extFile = (File)virtualComp.getAdapter(File.class);
+			if( extFile != null ) {
+				String name = null != archiveName ? archiveName : extFile.getName();
+				mf = new FlatFile(extFile, name, runtimePath.makeRelative());
+			}
+		}
+		
+		if( mf != null ) {
+			IFlatResource moduleParent = VirtualComponentFlattenUtility.getExistingModuleResource(members, mf.getModuleRelativePath());
+			if (moduleParent != null && moduleParent instanceof FlatFolder) {
+				VirtualComponentFlattenUtility.addMembersToModuleFolder((FlatFolder)moduleParent, new FlatResource[]{mf});
+			} else {
+				if( shouldAddComponentFile(virtualComp, mf)) {
+					if (mf.getModuleRelativePath().isEmpty()) {
+						for( IFlatResource tmp : members) 
+							if( tmp.getName().equals(mf.getName()))
+								return;
+						members.add(mf);
+					} else {
+						if (moduleParent == null) {
+							moduleParent = VirtualComponentFlattenUtility.ensureParentExists(members, mf.getModuleRelativePath(), (IContainer)parent.getRootFolder().getUnderlyingResource());
+						}
+						VirtualComponentFlattenUtility.addMembersToModuleFolder((FlatFolder)moduleParent, new FlatResource[] {mf});
+					}
+				} else {
+					// Automatically added to children if it needed to be
+				}
+			}
+		}
 	}
 }
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlatVirtualComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlatVirtualComponent.java
index e6ed33f..81b9b85 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlatVirtualComponent.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlatVirtualComponent.java
@@ -22,10 +22,21 @@
 	public static String PARTICIPANT_LIST = "org.eclipse.wst.common.componentcore.export.participantList";
 	
 	/**
-	 * The ExportModel (this) being used
+	 * The ExportModel being used; the value of this should be the IFlatVirtualComponent itself. 
 	 */
 	public static String EXPORT_MODEL = "org.eclipse.wst.common.componentcore.export.exportModel";
 
+	/**
+	 * Fetch the list of resources, which include raw files or folders only
+	 * @return
+	 * @throws CoreException
+	 */
 	public IFlatResource[] fetchResources() throws CoreException;
+	
+	/**
+	 * Fetch a list of child module references.
+	 * @return
+	 * @throws CoreException
+	 */
 	public IChildModuleReference[] getChildModules() throws CoreException;
 }
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipant.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipant.java
index a421e7f..32b17ae 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipant.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/flat/IFlattenParticipant.java
@@ -62,7 +62,7 @@
 	 * 
 	 * Only the first participant to claim it can optimize will be allowed to do so.
 	 * This will be the final list returned by ExportUtil.
-	 * No finalization of the list will take place
+	 * No finalization or other actions on this list will take place
 	 * 
 	 * @param component
 	 * @param dataModel
@@ -73,7 +73,15 @@
 			FlatComponentTaskModel dataModel, List<IFlatResource> resources);
 	
 	/**
-	 * Return true if this is a child module of the root component, false otherwise
+	 * Returns true if this participant considers this file to be a child module
+	 * The framework will consider the file a child module if at least one participant
+	 * returns true to this method. 
+	 * 
+	 * The item in question is a flat file which has been found inside the project
+	 * or inside a consumed reference of the project. The framework is asking
+	 * all participants if this file is a child module, to be exposed as such later, 
+	 * or if it is just a generic resource, which should be exposed as a regular member file. 
+	 * 
 	 * @param rootComponent
 	 * @param dataModel
 	 * @param file
@@ -106,9 +114,24 @@
 	
 	
 	/**
-	 * Is this referenced component recognized as a child module?
-	 * If any participant returns true, this reference will be 
-	 * cached as a child module
+	 * Returns true if this participant considers the reference a child module.
+	 * The framework will consider it a child module if at least one participant returns true. 
+	 * 
+	 * The framework is asking whether the referenced component is a child module, 
+	 * which should be added to the list of children modules and exposed as an  
+	 * IChildModuleReference, or if it is just some generic type of entity to be 
+	 * exposed as member resources inside the current flat component. 
+	 * 
+	 * The parameter "referenced" is guaranteed to be a "USED" reference,
+	 * as "CONSUMED" references have already been consumed directly into the project
+	 * as if they were part of it originally.  
+	 * 
+	 * A "USED" reference which is a child module will be exposed as an 
+	 * IChildModuleReference and use the archiveName retrieved from the IVirtualReference. 
+	 * 
+	 * A "USED" reference which is *not* a child module will be represented
+	 * as a folder member resource inside the parent, and the folder's name will
+	 * also be retrieved from the archiveName attribute of the IVirtualReference.
 	 * 
 	 * @param rootComponent
 	 * @param referenced