Index: tmp/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java
===================================================================
--- tmp/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java	(revision 1114)
+++ tmp/org.txm.links.rcp/src/org/txm/links/rcp/handlers/SendSelectionToQueryable.java	(revision 1115)
@@ -46,8 +46,6 @@
  */
 public abstract class SendSelectionToQueryable extends BaseAbstractHandler {
 
-	
-
 	/**
 	 * Creates the query.
 	 * @param isel
@@ -94,5 +92,4 @@
 		}
 		return null;
 	}
-
 }
Index: tmp/org.txm.core/src/java/org/txm/importer/xtz/ImportModule.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/xtz/ImportModule.java	(revision 1114)
+++ tmp/org.txm.core/src/java/org/txm/importer/xtz/ImportModule.java	(revision 1115)
@@ -74,14 +74,12 @@
 
 		
 		this.sourceDirectory = project.getSrcdir();
-		this.binaryDirectory = new File(Toolbox.getTxmHomePath(), "corpora/"+corpusName.toUpperCase());
-
-		if (!updateCorpus) { // clean directories only if it's a new import
-			DeleteDir.deleteDirectory(binaryDirectory);
-			binaryDirectory.mkdir();
+		this.binaryDirectory = project.getProjectDirectory();
 			
+		if (!updateCorpus) { // clean directories only if it's a new import	
 			File txmDir = new File(binaryDirectory, "txm");
-			txmDir.mkdir();
+			DeleteDir.deleteDirectory(binaryDirectory);
+			txmDir.mkdirs();
 		}
 	}
 
@@ -211,7 +209,7 @@
 		return isSuccessful;
 	}
 
-	public Project getParameters() {
+	public Project getProject() {
 		return project;
 	}
 
Index: tmp/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 1114)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 1115)
@@ -305,7 +305,7 @@
 			
 			//IScopeContext projectScope = new ProjectScope(projects[i]);
 
-			ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("project/" + projects[i].getName() + "/");
+			ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("P/" + projects[i].getName() + "/");
 			
 			Log.info("Toolbox.initialize(): loading project " + projects[i].getName() + "...");
 			Log.info("Toolbox.initialize(): " + resultNodePaths.size() + " node(s) found in project " + projects[i].getName() + "...");
Index: tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 1114)
+++ tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 1115)
@@ -183,7 +183,7 @@
 		}
 		if (parametersNodePath == null)	{
 			this.uniqueID = createUUID() + "_" + this.getClass().getSimpleName(); //$NON-NLS-1$
-			if(this.getProject() != null)	{
+			if (this.getProject() != null)	{
 				parametersNodePath = this.getProject().getParametersNodeRootPath();
 			}
 			this.parametersNodePath = parametersNodePath + this.uniqueID;
@@ -231,7 +231,7 @@
 		// retrieving parent from UUID
 		String parentUUID = this.getStringParameterValue(TXMPreferences.PARENT_UUID);
 		
-		System.out.println("TXMResult.TXMResult(): parent UUID = " + parentUUID);
+		//System.out.println("TXMResult.TXMResult(): parent UUID = " + parentUUID);
 		
 		if (!("ROOT".equals(this.uniqueID)) && // search for parent only if UUID != "ROOT"
 				parent == null && 
@@ -275,7 +275,6 @@
 		if (this.parent == null)	{
 			Log.warning("Warning: the TXMResult of " + this.getClass() + " is attached to no parent. (uuid = " + this.getUUID() + ")");
 		}
-
 	}
 
 	public void setUserName(String name) {
@@ -1005,16 +1004,20 @@
 			// FIXME: debug
 			// System.err.println("TXMResult.delete()");
 
-			// delete the local node
-			TXMPreferences.delete(this);
+			// START WITH CHILDREN
 
 			// remove children and clean resources
-			for (int i = 0; i < this.children.size(); i++) {
-				this.children.get(i).clean();
-				TXMPreferences.delete(this.children.get(i));
-				this.removeChild(i);
+			while (this.children.size() > 0) {
+				this.children.get(0).delete(); // should call parent.removeResult(child)
+//				TXMPreferences.delete(this.children.get(i));
+//				this.removeChild(i);
 			}
-
+			this.children.clear();
+			
+			//THEN FINISH WITH THIS
+			// delete the local node
+			TXMPreferences.delete(this);
+			
 			// specific cleaning
 			this.clean();
 
Index: tmp/org.txm.core/src/java/org/txm/objects/Project.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/objects/Project.java	(revision 1114)
+++ tmp/org.txm.core/src/java/org/txm/objects/Project.java	(revision 1115)
@@ -175,7 +175,7 @@
 	 * @throws Exception
 	 */
 	public Project(Workspace workspace, String name) throws Exception {
-		super(workspace);
+		super("project/" + name + "/" + createUUID() + "_Project", workspace);
 		this.internalPersistable = true;
 		this.pName = name;
 		this.dirty = false;
@@ -648,6 +648,9 @@
 	 * @return the base directory
 	 */
 	public File getProjectDirectory() {
+		if (this.rcpProject == null || this.rcpProject.getLocation() == null) {
+			return new File(Toolbox.workspace.getLocation(), this.pName);
+		}
 		return this.rcpProject.getLocation().toFile();
 	}
 
@@ -1003,7 +1006,7 @@
 		}
 		return null;
 	}
-
+	
 	@SuppressWarnings("unchecked")
 	private List<CorpusBuild> getCorpusBuilds() {
 		return (List<CorpusBuild>) getChildren(CorpusBuild.class);
Index: tmp/org.txm.core/src/java/org/txm/objects/Edition.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/objects/Edition.java	(revision 1114)
+++ tmp/org.txm.core/src/java/org/txm/objects/Edition.java	(revision 1115)
@@ -63,7 +63,7 @@
 
 	@Parameter(key=TBXPreferences.NAMES)
 	ArrayList<String> pPageNames = new ArrayList<String>();
-	
+
 	@Parameter(key="pages_wordids")
 	ArrayList<String> pPageFirstWordIds = new ArrayList<String>();
 
@@ -79,7 +79,7 @@
 		this.visible = false;
 		this.internalPersistable = true;
 	}
-	
+
 	/**
 	 * Instantiates a new edition.
 	 *
@@ -194,7 +194,7 @@
 		} catch (PatternSyntaxException pse) { }
 		return r;
 	}
-	
+
 	public void addPage(String id, String wordid) {
 		this.pPageNames.add(id);
 		this.pPageFirstWordIds.add(wordid);
@@ -361,17 +361,7 @@
 		} else {
 			pPageFirstWordIds = new ArrayList<>();
 		}
-		
-		if (pages == null) {
-			pages = new ArrayList<Page>();
-		} else {
-			pages.clear();
-		}
 
-		for (int i = 0 ; i < pPageNames.size() && i < pPageFirstWordIds.size() ; i++) {
-			pages.add(new Page(this, pPageNames.get(i), pPageFirstWordIds.get(i)));
-		}
-		
 		return true;
 	}
 
@@ -411,6 +401,18 @@
 	@Override
 	protected boolean _compute() throws Exception {
 		//System.out.println("USE THE PROJECT IMPORTMODULE TO BUILD THE EDITION="+pName);
+		if (pages == null) {
+			pages = new ArrayList<Page>();
+		} else {
+			pages.clear();
+		}
+		
+		if (pages.size() != pPageNames.size()) {
+			for (int i = 0 ; i < pPageNames.size() && i < pPageFirstWordIds.size() ; i++) {
+				pages.add(new Page(this, pPageNames.get(i), pPageFirstWordIds.get(i)));
+			}
+		}
+		
 		return true;
 	}
 
Index: tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java
===================================================================
--- tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 1114)
+++ tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java	(revision 1115)
@@ -313,7 +313,7 @@
 		this.nLines = queryResult.getNMatch();
 		this.lines = new ArrayList<Line>(Collections.nCopies(nLines, (Line) null));// lines are lazily fetched; we force an
 
-		return lines.size() > 0;
+		return true;//lines.size() > 0;
 	}
 
 	/**
Index: tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java
===================================================================
--- tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java	(revision 1114)
+++ tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java	(revision 1115)
@@ -127,6 +127,9 @@
 //					if (tempBinDirectory.exists()) tempBinDirectory.renameTo(basedir);
 					return new Status(Status.ERROR, "org.txm.groovy.core", "Import not correclty ended. See console messages.");
 				}
+			} else {
+				System.out.println("Error: import not correctly ended (no 'readyToLoad' binding found). See console messages.");
+				return new Status(Status.ERROR, "org.txm.groovy.core", "Import not correclty ended. See console messages.");
 			}
 		} catch (ThreadDeath td) {
 			return Status.CANCEL_STATUS;
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/hyperbaseLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/hyperbaseLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/hyperbaseLoader.groovy	(revision 1115)
@@ -43,40 +43,27 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/TESTS/hyperbase/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -114,7 +101,7 @@
 c.setAnnotationSuccess(annotationSuccess);
 if (debug) c.setDebug();
 c.setLang(lang);
-if (!c.run(binDir, txmDir, corpusname)) {
+if (!c.run(project, binDir, txmDir, corpusname)) {
 	println "import process stopped";
 	return;
 }
@@ -136,28 +123,33 @@
 
 	println "Paginating texts: "
 
-	for (File srcfile : filelist) {
+	for (File txmFile : filelist) {
 		print "."
-		String txtname = srcfile.getName();
+		String txtname = txmFile.getName();
 		int i = txtname.lastIndexOf(".");
 		if(i > 0) txtname = txtname.substring(0, i);
 
 		List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 		List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-		Element text = params.addText(params.corpora.get(corpusname), txtname, srcfile);
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)
 
-		def ed = new pager(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, "pb");
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
+		def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element);
+		Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 
 		for (i = 0 ; i < ed.getPageFiles().size();) {
 			File f = ed.getPageFiles().get(i);
 			String wordid = ed.getIdx().get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
+
+readyToLoad = project.save();
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy	(revision 1115)
@@ -33,7 +33,8 @@
 import org.txm.scripts.*;
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.treetagger.TreeTagger;
-
+import org.txm.objects.*
+import org.txm.searchengine.cqp.corpus.*
 import javax.xml.stream.*;
 import java.net.URL;
 import java.io.File;
@@ -77,9 +78,6 @@
 	/** The base. */
 	String base="";
 	
-	/** The project. */
-	String project="";
-	
 	/** The text attributes. */
 	String[] textAttributes = null;
 	
@@ -181,7 +179,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File binDir, File txmDir, String corpusname) 
+	public boolean run(Project project, File binDir, File txmDir, String corpusname) 
 	{
 		String rootDir = binDir.getAbsolutePath();
 		
@@ -189,17 +187,22 @@
 			println ("Error: CWB executables not well set.")
 			return false;
 		}
-		if(!binDir.exists())
-		{
-			println ("binary directory does not exists: "+rootDir)
-			return false;
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
 		}
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
 		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
-		new File(binDir,"cqp").deleteDir();
-		new File(binDir,"cqp").mkdir();
-		new File(binDir,"data").deleteDir();
-		new File(binDir,"data").mkdir();
-		new File(binDir,"registry").mkdir();
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 		
 		//start corpus
 		if (createOutput(cqpFile)) {
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy	(revision 1115)
@@ -33,6 +33,8 @@
 import org.txm.importer.cwb.*
 import org.txm.scripts.importer.*;
 import org.txm.scripts.*;
+import org.txm.objects.*;
+import org.txm.searchengine.cqp.corpus.*;
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.io.FileCopy;
 import org.txm.utils.treetagger.TreeTagger;
@@ -43,12 +45,10 @@
 import java.util.HashMap;
 import java.util.List;
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class compiler.
  */
-class compiler
-{
+class compiler {
 	/** The debug. */
 	boolean debug = false;
 
@@ -82,28 +82,28 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File binDir, String corpusname)
+	public boolean run(Project project, File binDir, String corpusname)
 	{
 		if (!(CwbEncode.isExecutableAvailable() && CwbMakeAll.isExecutableAvailable())) {
 			println ("Error: CWB executables not well set.")
 			return false;
 		}
-		if (!binDir.exists()) {
-			println ("binary directory does not exists: "+binDir)
-			return false;
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
 		}
-
-		if (!srcCQPFile.exists()) {
-			println "Error: cannot find the CQP file $srcCQPFile"
-			return false;
-		}
-
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
 		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
-		new File(binDir, "cqp").deleteDir();
-		new File(binDir, "cqp").mkdir();
-		new File(binDir, "data").deleteDir();
-		new File(binDir, "data").mkdir();
-		new File(binDir, "registry").mkdir();
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
 		FileCopy.copy(srcCQPFile, cqpFile);
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/cqpLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/cqpLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/cqpLoader.groovy	(revision 1115)
@@ -17,41 +17,27 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/cqp/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		//Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		//Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+Project project;
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
+
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -101,7 +87,7 @@
 println "-- COMPILING - Building Search Engine indexes"
 def c = new compiler(cqpFile, registryFile)
 c.setDebug(debug)
-if (!c.run(binDir, corpusname)) {
+if (!c.run(project, binDir, corpusname)) {
 	println "Import stopped"
 	return;
 }
@@ -131,13 +117,18 @@
 		def txtIndexes = allIndexes[txtname];
 		def txtPages = allPages[txtname];
 
-		Element text = params.addText(params.corpora.get(corpusname), txtname, cqpFile);
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(cqpFile)
+		t.setTXMFile(cqpFile)
+		
+		Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 		for (i = 0 ; i < txtPages.size();) {
 			File f = txtPages.get(i);
 			String wordid = txtIndexes.get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
@@ -145,5 +136,5 @@
 
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy	(revision 1115)
@@ -8,7 +8,7 @@
 import org.txm.utils.io.*
 import org.txm.importer.xtz.*
 
-public class XTZCompilerStep {
+public class XTZCompilerStep extends Step {
 
 	static String FORM = "form";
 	static String ANA = "ana";
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy	(revision 1115)
@@ -11,6 +11,8 @@
 
 import javax.xml.stream.*
 import org.txm.importer.xtz.*
+import org.txm.objects.*
+import org.txm.searchengine.cqp.corpus.*
 
 class XTZCompiler extends Compiler {
 
@@ -27,13 +29,13 @@
 	public XTZCompiler(ImportModule module) {
 		super(module);
 
-		corpusname = module.getParameters().getCorpusName();
+		corpusname = module.getProject().getName();
 		regPath = module.getBinaryDirectory().getAbsolutePath() + "/registry/"+corpusname.toLowerCase()
 		
-		wtag = module.getParameters().getWordElement().getTextContent();
+		wtag = module.getProject().getTokenizerParameter("wordelement", "w");
 		
-		doNormalizeAttributeValues = "true".equals(module.getParameters().getKeyValueParameters().get(ImportKeys.NORMALISEATTRIBUTEVALUES))
-		doNormalizeAnaValues = "true".equals(module.getParameters().getKeyValueParameters().get(ImportKeys.NORMALISEANAVALUES))
+		doNormalizeAttributeValues = "true".equals(module.getProject().getPreferences().getNode("import").get(ImportKeys.NORMALISEATTRIBUTEVALUES))
+		doNormalizeAnaValues = "true".equals(module.getProject().getPreferences().getNode("import").get(ImportKeys.NORMALISEANAVALUES))
 	}
 
 	public void process(ArrayList<File> files) {
@@ -46,7 +48,19 @@
 		if (!doCWBEncodeStep()) return;
 		if (!doCWBMakeAllStep()) return;
 		
-		String cleanDirectories = module.getParameters().getKeyValueParameters().get(ImportKeys.CLEAN);
+		CorpusBuild corpus = module.getProject().getCorpusBuild(corpusname);
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
+		}
+		
+		// make new one
+		corpus = new MainCorpus(module.getProject());
+		corpus.setID(corpusname);
+		corpus.setName(corpusname);
+		corpus.setDescription("Built with the XTZ import module");
+		
+		String cleanDirectories = module.getProject().getPreferences().getNode("import").get(ImportKeys.CLEAN, "true");
 		if ("true".equals(cleanDirectories)) {
 			new File(module.getBinaryDirectory(), "cqp").deleteDir()
 		}
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy	(revision 1115)
@@ -37,17 +37,17 @@
 import org.txm.importer.cwb.CwbEncode
 import org.txm.importer.cwb.CwbMakeAll
 import org.txm.scripts.importer.*;
+import org.txm.objects.*;
 import org.txm.scripts.*;
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.treetagger.TreeTagger;
-
+import org.txm.searchengine.cqp.corpus.*
 import javax.xml.stream.*;
 import java.net.URL;
 import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class compiler.
  */
@@ -82,7 +82,7 @@
 	String base="";
 
 	/** The project. */
-	String project="";
+	String projectName="";
 
 	/** The lang. */
 	private String lang ="fr";
@@ -108,11 +108,11 @@
 	 * @param base the base
 	 * @param project the project
 	 */
-	public compiler(URL url,String text,String base, String project)
+	public compiler(URL url,String text,String base, String projectName)
 	{
 		this.text = text
 		this.base = base;
-		this.project = project;
+		this.projectName = projectName;
 		try {
 			this.url = url;
 			inputData = url.openStream();
@@ -265,7 +265,7 @@
 								}
 
 								if (parser.getLocalName() == "text") {
-									output.write(" id=\""+text+"\" base=\""+base+"\" project=\""+project+"\"");
+									output.write(" id=\""+text+"\" base=\""+base+"\" project=\""+projectName+"\"");
 								}
 								output.write(">\n");
 							}
@@ -340,7 +340,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File binDir, File txmDir, String basename, String corpusname, List<File> files)
+	public boolean run(Project project, File binDir, File txmDir, String basename, String corpusname, List<File> files)
 	{
 		anatypes = new ArrayList<String>();// init only 1 time
 		anavalues = [:]
@@ -351,18 +351,23 @@
 			println ("Error: CWB executables not well set.")
 			return false;
 		}
-		if(!new File(rootDir).exists()) {
-			println ("binary directory does not exists: "+rootDir)
-			return false;
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
 		}
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
+		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
-		File cqpFile = new File(binDir,"cqp/"+corpusname.toLowerCase()+".cqp");
-		new File(rootDir,"/cqp/").deleteDir();
-		new File(rootDir,"/cqp/").mkdir();
-		new File(rootDir,"data/"+corpusname).deleteDir();
-		new File(rootDir,"data/"+corpusname).mkdir();
-		new File(rootDir,"registry/").mkdir();
-
 		String textid = "";
 		int counttext = 0;
 		//List<File> files = txmDir.listFiles();
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/xmltxmLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/xmltxmLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/xmltxmLoader.groovy	(revision 1115)
@@ -53,41 +53,27 @@
 import org.txm.importer.*
 
 String userDir = System.getProperty("user.home");
-boolean debug = false
-def MONITOR;
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/anapovoas/FOLLOWING TEST OF MATTHIEU/OUTPUT 2/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+Project project;
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
+
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-String page_element = params.getPageElement("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -191,7 +177,7 @@
 def c = new compiler();
 if (debug) c.setDebug();
 c.setLang(lang);
-if (!c.run(binDir, txmDir, basename, corpusname, Arrays.asList(files))) {
+if (!c.run(project, binDir, txmDir, basename, corpusname, Arrays.asList(files))) {
 	println "import process stopped";
 	return;
 }
@@ -211,32 +197,35 @@
 	def second = 0
 
 	println "Paginating text: "
-	for (File srcfile : files) {
+	for (File txmFile : files) {
 
-		String txtname = srcfile.getName();
+		String txtname = txmFile.getName();
 		int i = txtname.lastIndexOf(".");
 		if(i > 0) txtname = txtname.substring(0, i);
 
 		List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 		List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-		Element text = params.addText(params.corpora.get(corpusname), txtname, srcfile);
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)
 
 		if (second) { print(", ") }
 		if (second > 0 && (second++ % 5) == 0) println ""
 		print(".");
 
-		def ed = new pager(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element);
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-
+		def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element);
+		Edition edition = new Edition(t);
+			edition.setName("default");
+			edition.setIndex(outdir.getAbsolutePath());
 		for (i = 0 ; i < ed.getPageFiles().size();) {
 			File f = ed.getPageFiles().get(i);
 			String wordid = ed.getIdx().get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy	(revision 1115)
@@ -34,14 +34,14 @@
 import org.txm.scripts.*;
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.treetagger.TreeTagger;
-
+import org.txm.objects.*
 import javax.xml.stream.*;
 import java.net.URL;
 import java.io.File;
 import java.util.HashMap;
 import java.util.List;
+import org.txm.searchengine.cqp.corpus.*
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class compiler.
  */
@@ -74,9 +74,6 @@
 	/** The base. */
 	String base="";
 
-	/** The project. */
-	String project="";
-
 	/** The lang. */
 	private String lang ="fr";
 
@@ -99,10 +96,9 @@
 	 * @param base the base
 	 * @param project the project
 	 */
-	public compiler(URL url,String text,String base, String project) {
+	public compiler(URL url,String text,String base, String projectName) {
 		this.text = text
 		this.base = base;
-		this.project = project;
 		try {
 			this.url = url;
 			inputData = url.openStream();
@@ -172,20 +168,29 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(List<File> files, File binDir, File txmDir, String corpusname) {
+	public boolean run(Project project, List<File> files, File binDir, File txmDir, String corpusname) {
 		String binDirPath = binDir.getAbsolutePath()+"/";
 
 		if (!(CwbEncode.isExecutableAvailable() && CwbMakeAll.isExecutableAvailable())) {
 			println ("Error: CWB executables not well set.")
 			return false;
 		}
-		File cqpFile = new File(binDir,"cqp/${corpusname}.cqp");
-		new File(binDir, "cqp.").deleteDir();
-		new File(binDir, "cqp").mkdirs();
-		new File(binDir, "data/$corpusname").deleteDir();
-		new File(binDir, "data/$corpusname").mkdir();
-		new File(binDir, "registry").deleteDir();
-		new File(binDir, "registry").mkdir();
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
+		}
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
+		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
 		//start corpus
 		if (createOutput(cqpFile)) {
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/discoursLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/discoursLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/discoursLoader.groovy	(revision 1115)
@@ -40,40 +40,27 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true;
-	params = new BaseParameters(new File(userDir, "xml/discours/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -104,7 +91,7 @@
 if (debug) c.setDebug();
 // no annotation
 c.setLang(lang);
-if (!c.run(files, binDir, txmDir, corpusname)) {
+if (!c.run(project, files, binDir, txmDir, corpusname)) {
 	println "import process stopped";
 	return;
 }
@@ -125,28 +112,31 @@
 
 	println "Paginating texts: "
 
-	for (File srcfile : filelist) {
+	for (File txmFile : filelist) {
 		print "."
-		String txtname = srcfile.getName();
+		String txtname = txmFile.getName();
 		int i = txtname.lastIndexOf(".");
 		if(i > 0) txtname = txtname.substring(0, i);
 
 		List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 		List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-		Element text = params.addText(params.corpora.get(corpusname), txtname, srcfile);
-
-		def ed = new pager(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, "pb");
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)
+		def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, "pb");
+		Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 		for (i = 0 ; i < ed.getPageFiles().size();) {
 			File f = ed.getPageFiles().get(i);
 			String wordid = ed.getIdx().get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+	
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy	(revision 1115)
@@ -49,15 +49,15 @@
 import org.txm.scripts.*;
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.treetagger.TreeTagger;
-
+import org.txm.objects.*
 import javax.xml.stream.*;
 import java.net.URL;
 import java.io.File;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
+import org.txm.searchengine.cqp.corpus.*
 
-// TODO: Auto-generated Javadoc
 /**
  * Produce CQP files from the TEI-TXM files. <br/>
  * - Read texts metadata with XPath queries <br/>
@@ -108,9 +108,6 @@
 	/** The base. */
 	private String base="";
 
-	/** The project. */
-	private String project="";
-
 	/** The lang. */
 	private String lang ="fr";
 
@@ -136,12 +133,11 @@
 	 * @param base the base's name
 	 * @param project the Project's name
 	 */
-	public compiler(URL url,String text,String base, String project, Properties metadataXPath)
+	public compiler(URL url,String text,String base, String projectName, Properties metadataXPath)
 	{
 		this.metadataXPath = metadataXPath;
 		this.text = text
 		this.base = base;
-		this.project = project;
 		try {
 			this.url = url;
 			inputData = url.openStream();
@@ -249,7 +245,7 @@
 	 * @param fileName the file name
 	 * @return true, if successful
 	 */
-	private boolean transfomFileCqp(File cqpFile)
+	private boolean transfomFileCqp(Project project, File cqpFile)
 	{
 		try {
 			if (!createOutput(cqpFile)) return false;
@@ -349,7 +345,7 @@
 									}
 								}
 								
-								output.write(" base=\""+base+"\" project=\""+project+"\">\n");
+								output.write(" base=\""+base+"\" project=\""+project.getName()+"\">\n");
 								captureword=true;
 								break;
 
@@ -746,7 +742,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File binDir, File txmDir, String corpusname, Properties metadataXPath)
+	public boolean run(Project project, File binDir, File txmDir, String corpusname, Properties metadataXPath)
 	{
 		sattrsListener = null; // reset SAttribute Listener for each new import
 		this.metadataXPath = metadataXPath;
@@ -754,19 +750,25 @@
 		if (!(CwbEncode.isExecutableAvailable() && CwbMakeAll.isExecutableAvailable())) {
 			println ("Error: CWB executables not well set.")
 			return false;
-		}
-		if (!txmDir.exists()) {
-			println ("binary directory does not exists: "+txmDir)
-			return false;
-		}
+		}
+		
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
+		}
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
+		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
-		File cqpFile = new File(binDir, "cqp/${corpusname}.cqp");
-		new File(binDir, "/cqp/").deleteDir();
-		new File(binDir, "/cqp/").mkdir();
-		new File(binDir, "/data/${corpusname}").deleteDir();
-		new File(binDir, "/data/${corpusname}").mkdir();
-		new File(binDir, "registry/").mkdir();
-
 		String textid = "";
 		int counttext = 0;
 		List<File> files = txmDir.listFiles();
@@ -847,7 +849,7 @@
 				String txtname = f.getName().substring(0, f.getName().length()-4);
 				def builder = new compiler(f.toURI().toURL(), txtname, corpusname, "default", metadataXPath);
 				builder.setLang(lang)
-				if (!builder.transfomFileCqp(cqpFile)) {
+				if (!builder.transfomFileCqp(project, cqpFile)) {
 					println "Failed to compile "+f
 				}
 				builder.setAnnotationDone(this.annotate_status);
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/bfmLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/bfmLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/bfmLoader.groovy	(revision 1115)
@@ -45,44 +45,27 @@
 import org.txm.importer.*
 
 String userDir = System.getProperty("user.home");
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-def MONITOR;
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/bfm/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
-		//rootDir = userDir+"/xml/TESTS/alceste";  // directory which contains the source file
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		//Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -166,7 +149,7 @@
 //c.setCwbPath("~/TXM/cwb/bin");
 c.setLang(lang);
 c.setAnnotationDone(annotate_status)
-if (!c.run(binDir, txmDir, corpusname, metadataXPath)) {
+if (!c.run(project, binDir, txmDir, corpusname, metadataXPath)) {
 	println "import process stopped";
 	return;
 }
@@ -192,19 +175,23 @@
 		List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 		List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);//["'","(","[","{","«"];
 
-		Element text = params.addText(corpusElem, txtname, txmFile);
-
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)
+		
 		def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, corpusname, metadataXPath);
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-
+		Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 		for (i = 0 ; i < ed.getPageFiles().size();) {
 			File f = ed.getPageFiles().get(i);
 			String wordid = ed.getIdx().get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/pager.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/pager.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/pager.groovy	(revision 1115)
@@ -404,6 +404,7 @@
 									createNextOutput();
 								}
 								break;
+								
 							case "list":
 								pagedWriter.writeEndElement(); // ul or ol
 								pagedWriter.writeCharacters("\t")
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy	(revision 1115)
@@ -37,9 +37,9 @@
 import org.txm.importer.scripts.xmltxm.*;
 import org.txm.utils.logger.Log;
 import org.txm.utils.treetagger.TreeTagger;
-
+import org.txm.objects.*;
+import org.txm.searchengine.cqp.corpus.*;
 import javax.xml.stream.*;
-
 import java.net.URL;
 import java.io.File;
 import java.io.IOException;
@@ -47,12 +47,10 @@
 import java.util.HashMap;
 import java.util.List;
 
-// TODO: Auto-generated Javadoc
 /**
- * The Class compiler.
+ * The Class compiler builds the aligned CQP corpus indexes
  */
-class compiler
-{
+class compiler {
 	/** The debug. */
 	private boolean debug= false;
 
@@ -81,7 +79,7 @@
 	String base="";
 
 	/** The project. */
-	String project="";
+	String projectName="";
 
 	/** The anahash. */
 	static boolean firstWord = true;
@@ -130,7 +128,7 @@
 	{
 		this.text = text
 		this.base = base;
-		this.project = project;
+		this.projectName = project;
 		this.tuprops = tuprops;
 		try {
 			this.url = url;
@@ -222,7 +220,7 @@
 								break;
 							case "text":
 								output.write("<text id=\""+text+"\" base=\""+base+"\"" +
-								" project=\""+project+"\"");
+								" project=\""+projectName+"\"");
 								def textAttrs = [];
 								for ( int i = 0 ; i < parser.getAttributeCount() ; i++)
 								{
@@ -424,7 +422,7 @@
 	 * @param textAttributes the text attributes
 	 * @return true, if successful
 	 */
-	public boolean run(File binDir, File txmDir, String basename)
+	public boolean run(Project project, File binDir, File txmDir, String basename)
 	{
 		sattrsListener = null; // reset SAttribute Listener for each new import
 		String rootDir = binDir.getAbsolutePath();
@@ -434,17 +432,11 @@
 			println ("Error: CWB executables not well set.")
 			return false;
 		}
-		if (!new File(rootDir).exists()) {
-			println ("binary directory does not exists: "+rootDir)
-			return false;
-		}
+		
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
-		new File(binDir,"/cqp/").deleteDir();
-		new File(binDir,"/cqp/").mkdir();
-		new File(binDir,"/data/").deleteDir();
-		new File(binDir,"/data/").mkdir();
-		new File(binDir,"registry/").mkdir();
-
 		String textid="";
 		int counttext =0;
 		List<File> files = txmDir.listFiles();
@@ -459,7 +451,7 @@
 				if (lang ==null) {
 					println "ERROR: no lang defined for group $group . Aborting."
 				}
-				corpusIDS[group] = (lang+group).toLowerCase();
+				corpusIDS[group] = lang+group
 			}
 		}
 		println "Using corpus ID: $corpusIDS"
@@ -470,7 +462,7 @@
 			segs_id.put(group, 0);
 			cqpName = basename+"_"+corpusIDS.get(group);
 			createOutput(rootDir+"/cqp", "${cqpName}.cqp");
-			output.write("<txmcorpus id=\"${cqpName}\" lang=\"$lang\">\n")
+			output.write("<txmcorpus id=\"${cqpName}\" lang=\""+lang.toLowerCase()+"\">\n")
 			output.close();
 
 			//create txmDirs
@@ -484,6 +476,21 @@
 		for (int group : langGroups.keySet()) {
 			//String lang = langs.get(langGroups.get(group)[0]);
 			cqpName = basename+"_"+corpusIDS.get(group);
+			
+			CorpusBuild corpus = project.getCorpusBuild(cqpName);
+			if (corpus != null) {
+				//println "CLEAN PREVIOUS CORPUS"
+				corpus.delete(); // remove old files
+			}
+				
+			// make new one
+			corpus = new MainCorpus(project);
+			corpus.setID(cqpName);
+			corpus.setName(cqpName);
+			corpus.setDescription("Built with the TMX import module");
+			
+			File cqpFile = new File(binDir,"cqp/"+cqpName+".cqp");
+			
 			def filenames = langGroups.get(group);
 			filenames.sort()
 			//println("Process group no $group of files "+filenames)
@@ -496,11 +503,10 @@
 				}
 
 				filename = filename.substring(0, filename.length()-4);
-				String corpusname = (cqpName).toLowerCase();
 				counttext++;
 
 				String txtname = f.getName();
-				txtname = txtname.substring(0, txtname.lastIndexOf("_"));
+				txtname = txtname.substring(0, txtname.lastIndexOf(".xml"));
 				seg_id = segs_id.get(group);
 				builder = new compiler(f.toURI().toURL(), txtname, basename, "default", tuprops);
 				builder.transfomFileCqp(rootDir+"/cqp",cqpName+".cqp");
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/Tmx2XmlFiles.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/Tmx2XmlFiles.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/Tmx2XmlFiles.groovy	(revision 1115)
@@ -136,11 +136,11 @@
 			if (event == XMLStreamConstants.START_ELEMENT) {
 				if (parser.getLocalName() == "tuv") {
 
-					String lang = "fr";
+					String lang = "FR";
 					for(int i = 0 ; i < parser.getAttributeCount() ; i++)
 						if (parser.getAttributeLocalName(i) == "lang")
 					{
-						lang = (parser.getAttributeValue(i)).toLowerCase()
+						lang = (""+parser.getAttributeValue(i)).toUpperCase()
 						break;
 					}
 
@@ -249,7 +249,7 @@
 							for (int i = 0 ; i < parser.getAttributeCount() ; i++) // get the lang attribute of the tuv
 								if (parser.getAttributeLocalName(i) == "lang")
 							{
-								lang = parser.getAttributeValue(i)
+								lang = (""+parser.getAttributeValue(i)).toUpperCase()
 								break;
 							}
 							
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/tmxLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/tmxLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/tmxLoader.groovy	(revision 1115)
@@ -43,43 +43,28 @@
 import org.txm.utils.xml.DomUtils;
 
 String userDir = System.getProperty("user.home");
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
 def MONITOR;
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/tmx/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File(userDir,"treetagger/models"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
-String model = lang;
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);;
-int wordsPerPage = params.getWordsPerPage("default")
-String page_element = params.getPageElement("default")
-boolean build_edition = params.getDoEdition("default")
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
+String model = lang
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -118,7 +103,7 @@
 c.setLangs(textLangs);
 c.setCorpusIDS(corpusIDS);
 c.setLangGroups(langGroups);
-if (!c.run(binDir, txmDir, basename)) {
+if (!c.run(project, binDir, txmDir, basename)) {
 	println "Compiler failed"
 	return;
 }
@@ -127,10 +112,10 @@
 new File(binDir,"HTML").deleteDir();
 new File(binDir,"HTML").mkdirs();
 if (build_edition) {
-	
+
 	println "-- EDITION - Building edition"
 	if (MONITOR != null) MONITOR.worked(20, "EDITION - Building edition")
-	
+
 	List<File> filelist = new File(binDir,"txm").listFiles();
 	def second = 0
 
@@ -145,13 +130,13 @@
 		outdir.mkdirs();
 		//println "processing pages of corpus "+txmCorpusDir.getName()
 
-		Element paraCorpusElem = corpusElem.cloneNode(true);
-		paraCorpusElem.setAttribute("name", txmCorpusDir.getName());
+		//		Element paraCorpusElem = corpusElem.cloneNode(true);
+		//		paraCorpusElem.setAttribute("name", txmCorpusDir.getName());
 
-		for (File srcfile : txmFiles) {
+		for (File txmFile : txmFiles) {
 			print "."
-			String txtname = srcfile.getName();
-			int i = txtname.lastIndexOf("_");
+			String txtname = txmFile.getName();
+			int i = txtname.lastIndexOf(".xml");
 			if(i > 0) txtname = txtname.substring(0, i);
 
 			//println ""+srcfile.getName()+" -> "+splitTUsPerText[txtname]
@@ -161,25 +146,27 @@
 				splitTUsPerText[txtname] = splitTUs;
 			}
 
-			String l = textLangs.get(srcfile.getName())
+			String l = textLangs.get(txmFile.getName()).toLowerCase()
 			if (l == null) l = "fr";
 			List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(l);
 			List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(l);
 
-			Element text = params.addText(paraCorpusElem, txtname, srcfile);
+			Text t = new Text(project);
+			t.setName(txtname);
+			t.setSourceFile(txmFile)
+			t.setTXMFile(txmFile)
 
-			def ed = new pager(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element,splitTUs);
-			Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-
+			def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element,splitTUs);
+			Edition edition = new Edition(t);
+			edition.setName("default");
+			edition.setIndex(outdir.getAbsolutePath());
 			for (i = 0 ; i < ed.getPageFiles().size();) {
 				File f = ed.getPageFiles().get(i);
 				String wordid = ed.getIdx().get(i);
-				params.addPage(edition, ""+(++i), wordid);
+				edition.addPage(""+(++i), wordid);
 			}
 		}
 
-		params.corporaElement.appendChild(paraCorpusElem);
-
 		File cssfile = new File(Toolbox.getTxmHomePath(), "css/tmx.css")
 		if (cssfile.exists()) {
 			FileCopy.copy(cssfile, new File(outdir, "tmx.css"));
@@ -191,9 +178,8 @@
 		println ""
 	}
 }
-params.corporaElement.removeChild(corpusElem);
 
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivamailLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivamailLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivamailLoader.groovy	(revision 1115)
@@ -42,39 +42,27 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception) {
-	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/factivatxt/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -119,7 +107,7 @@
 c.setAnnotationSuccess(annotationSuccess)
 if (debug) c.setDebug();
 c.setLang(lang);
-if (!c.run(binDir, txmDir, corpusname)) {
+if (!c.run(project)) {
 	println "import process stopped";
 	return;
 }
@@ -135,27 +123,30 @@
 def second = 0
 
 println "Paginating texts: "
-for (File srcfile : filelist) {
+for (File txmFile : filelist) {
 	print "."
-	String txtname = srcfile.getName();
+	String txtname = txmFile.getName();
 	int i = txtname.lastIndexOf(".");
 	if(i > 0) txtname = txtname.substring(0, i);
 	
 	List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 	List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-	Element text = params.addText(params.corpora.get(corpusname), txtname, srcfile);
-		
+	Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)	
 	def ed = new pager_old(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, 500, basename, "pb");
-	Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
-	
+	Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 	for (i = 0 ; i < ed.getPageFiles().size();) {
 		File f = ed.getPageFiles().get(i);
 		String wordid = ed.getIdx().get(i);
-		params.addPage(edition, ""+(++i), wordid);
+		edition.addPage(""+(++i), wordid);
 	}
 }
 
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
+	
+readyToLoad = project.save();
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivaLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivaLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivaLoader.groovy	(revision 1115)
@@ -49,41 +49,27 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true;
-	params = new BaseParameters(new File(userDir, "xml/TESTS/factiva/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
+Project project;
 
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
-}
-if (params == null) { println "no parameters. Aborting"; return; }
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-String page_element = params.getPageElement("default")
-boolean build_edition = params.getDoEdition("default")
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
 
 File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -242,7 +228,7 @@
 c.setOptions(textSortAttribute, normalizeMetadata);
 c.setAnnotationSuccess(annotationSuccess)
 c.setLang(lang);
-if (!c.run(binDir, txmDir, corpusname, null, srcfiles, metadatas)) {
+if (!c.run(project, binDir, txmDir, corpusname, null, srcfiles, metadatas)) {
 	println "import process stopped";
 	return;
 }
@@ -273,19 +259,24 @@
 		List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 		List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-		Element text = params.addText(corpusElem, txtname, txmFile);
+		Text t = new Text(project);
+		t.setName(txtname);
+		t.setSourceFile(txmFile)
+		t.setTXMFile(txmFile)
 
 		def ed = new pager(txmFile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element);
-		Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html");
+		Edition edition = new Edition(t);
+		edition.setName("default");
+		edition.setIndex(outdir.getAbsolutePath());
 
 		for (i = 0 ; i < ed.getPageFiles().size();) {
 			File f = ed.getPageFiles().get(i);
 			String wordid = ed.getIdx().get(i);
-			params.addPage(edition, ""+(++i), wordid);
+			edition.addPage(""+(++i), wordid);
 		}
 	}
 }
 
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
\ No newline at end of file
+	
+readyToLoad = project.save();
\ No newline at end of file
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy	(revision 1115)
@@ -67,48 +67,33 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-boolean debug = org.txm.utils.logger.Log.isPrintingErrors();
-BaseParameters params;
-try {params = paramsBinding;MONITOR=monitor} catch (Exception)
-{	println "DEV MODE";//exception means we debug
-	debug = true
-	params = new BaseParameters(new File(userDir, "xml/anapovoas/import.xml"))
-	params.load()
-	if (!org.txm.Toolbox.isInitialized()) {
-
-		Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
-		Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File(userDir,"treetagger/models"));
-		Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
-		Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, "\t");
-		Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "");
-		Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
-	}
+Project project;
+
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
+{	}
+if (project == null) { println "no project set. Aborting"; return; }
+
+String corpusname = project.getName();
+String basename = corpusname
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
+String model = lang
+String encoding = project.getEncoding()
+boolean annotate = project.getAnnotate()
+String xsl = project.getFrontXSL();
+def xslParams = project.getXsltParameters();
+int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
+String page_element = project.getEditionDefinition("default").getPageElement()
+boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
+
+File srcDir = new File(rootDir);
+File binDir = project.getProjectDirectory();
+binDir.mkdirs();
+if (!binDir.exists()) {
+	println "Could not create binDir "+binDir
+	return;
 }
-if (params == null) { println "no parameters. Aborting"; return; }
 
-String corpusname = params.getCorpusName();
-Element corpusElem = params.corpora.get(corpusname);
-String basename = params.name;
-String rootDir = params.rootDir;
-String lang = corpusElem.getAttribute("lang");
-String model = lang
-String encoding = corpusElem.getAttribute("encoding");
-boolean annotate = "true" == corpusElem.getAttribute("annotate");
-String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
-def xslParams = params.getXsltParams(corpusElem);
-int wordsPerPage = params.getWordsPerPage("default")
-String page_element = params.getPageElement("default")
-boolean build_edition = params.getDoEdition("default")
-
-File srcDir = new File(rootDir);
-File binDir = new File(Toolbox.getTxmHomePath(),"corpora/"+basename);
-binDir.deleteDir();
-binDir.mkdirs();
-if (!binDir.exists()) {
-	println "Could not create binDir "+binDir
-	return;
-}
-
 File txmDir = new File(binDir,"txm/$corpusname");
 txmDir.deleteDir();
 txmDir.mkdirs();
@@ -123,9 +108,9 @@
 		println "Error: could not create a copy of metadata file "+allMetadataFile.getAbsoluteFile();
 		return;
 	}
-	metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), 
-		Toolbox.getMetadataColumnSeparator(), 
-		Toolbox.getMetadataTextSeparator(), 1)
+	metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(),
+			Toolbox.getMetadataColumnSeparator(),
+			Toolbox.getMetadataTextSeparator(), 1)
 }
 else
 	println "no metadata file: "+allMetadataFile
@@ -156,6 +141,8 @@
 	println " ignored csvHeaderSize: "+csvHeaderNumber
 	//println " includeComments: "+includeComments
 }
+
+
 
 // Apply XSL
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
@@ -235,12 +222,12 @@
 	if (MONITOR != null) MONITOR.worked(20, "ANNOTATE")
 	println "-- ANNOTATE - Running NLP tools"
 	boolean annotationSuccess = false;
-if (annotate) {
-	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
-	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
-		annotationSuccess = true;
-	}
-}
+	if (annotate) {
+		def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
+		if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
+			annotationSuccess = true;
+		}
+	}
 
 	if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 	if (MONITOR != null) MONITOR.worked(25, "COMPILING")
@@ -252,21 +239,21 @@
 	comp.removeInterviewers(removeInterviewer);
 	comp.setIgnoreTranscriberMetadata(ignoreTranscriberMetadata);
 	comp.setAnnotationSucces(annotationSuccess)
-	if (!comp.run(trsfiles, corpusname, "default", binDir)) {
+	if (!comp.run(project, trsfiles, corpusname, "default", binDir)) {
 		println "Failed to compile files";
 		return;
 	}
-	
+
 	if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
-	
+
 	File htmlDir = new File(binDir,"HTML/$corpusname");
 	htmlDir.deleteDir()
 	htmlDir.mkdirs();
 	if (build_edition) {
-		
+
 		if (MONITOR != null) MONITOR.worked(20, "EDITION")
 		println "-- EDITION - Building editions"
-		
+
 		List<File> filelist = txmDir.listFiles();
 		Collections.sort(filelist);
 		def second = 0
@@ -281,21 +268,20 @@
 			List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 			List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-			Element text = params.addText(corpusElem, txtname, txmFile);
+			Text t = new Text(project);
+			t.setName(txtname);
+			t.setSourceFile(txmFile)
+			t.setTXMFile(txmFile)
 
 			def ed = new pager(txmFile, htmlDir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, page_element, metadatas);
-			Element edition = params.addEdition(text, "default", htmlDir.getAbsolutePath(), "html");
-
+			Edition edition = new Edition(t);
+			edition.setName("default");
+			edition.setIndex(htmlDir.getAbsolutePath());
 			for (i = 0 ; i < ed.getPageFiles().size();) {
 				File f = ed.getPageFiles().get(i);
 				String wordid = ed.getIdx().get(i);
-				params.addPage(edition, ""+(++i), wordid);
+				edition.addPage(""+(++i), wordid);
 			}
-
-			if (ed.getPageFiles().size() > 0) {
-				Element editionBD = params.addEdition(text, "onepage", htmlDir.getAbsolutePath(), "html");
-				params.addPage(editionBD, "1", ed.getIndexes().get(0));
-			}
 		}
 
 		//copy transcriber.css
@@ -311,5 +297,4 @@
 
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-File paramFile = new File(binDir, "import.xml");
-DomUtils.save(params.root.getOwnerDocument(), paramFile);readyToLoad = true;
+readyToLoad = project.save();
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy	(revision 1114)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy	(revision 1115)
@@ -33,14 +33,14 @@
 
 import java.io.OutputStreamWriter;
 import java.util.LinkedHashMap;
-
+import org.txm.objects.*
+import org.txm.searchengine.cqp.corpus.*
 import org.txm.importer.cwb.CwbEncode
 import org.txm.importer.cwb.CwbMakeAll
 import org.txm.importer.cwb.CwbProcess;
 import org.txm.importer.cwb.PatchCwbRegistry;
 import org.txm.utils.Pair;
 
-// TODO: Auto-generated Javadoc
 /**
  * The Class compiler.
  */
@@ -109,6 +109,7 @@
 		this.removeinterviewers = value;
 	}
 
+	File cqpFile
 	/**
 	 * Run.
 	 *
@@ -118,8 +119,7 @@
 	 * @param outdir the outdir
 	 * @return true, if successful
 	 */
-	public boolean run(List<File> xmlfiles, String corpusname, String projectname, File binDir)
-	{
+	public boolean run(Project project, List<File> xmlfiles, String corpusname, String projectname, File binDir) {
 		Collections.sort(xmlfiles);
 		//println "run compiler with $xmlfiles, $basename and $outdir"
 		this.outdir = binDir;
@@ -131,16 +131,23 @@
 
 		sectionAttrs = new HashSet<String>() // reset section attributs set
 
-		File cqpDir = new File(binDir, "cqp")
-		new File(binDir, "cqp").delete();
-		cqpDir.mkdir();
-		if (!new File(binDir, "cqp").exists()) {
-			println "Can't create cqp directory"
-			return false;
+		CorpusBuild corpus = project.getCorpusBuild(project.getName());
+		if (corpus != null) {
+			//println "CLEAN PREVIOUS CORPUS"
+			corpus.delete(); // remove old files
 		}
+			
+		// make new one
+		corpus = new MainCorpus(project);
+		corpus.setID(project.getName());
+		corpus.setName(project.getName());
+		corpus.setDescription("Built with the TXT+CSV import module");
+		
+		cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
+		new File(binDir,"cqp").mkdirs()
+		new File(binDir,"data").mkdirs()
+		new File(binDir,"registry").mkdirs()
 
-		File cqpFile = new File(cqpDir, corpusname.toLowerCase()+".cqp")
-
 		// get all anatypes
 		for (File f : xmlfiles) {
 			getAnaTypes(f)
@@ -223,11 +230,9 @@
 				return false;
 			}
 			cwbMa.run(corpusname, registryFile.getParent());
-			
 
 		} catch (Exception ex) {System.out.println(ex); return false;}
 
-
 		return true;
 	}
 
@@ -311,7 +316,7 @@
 		String filename = xmlfile.getName()
 		String textid = filename.substring(0, filename.length() - 4);
 
-		createOutput(new File(outdir, "cqp/"+corpusname.toLowerCase()+".cqp"));
+		createOutput(cqpFile);
 		String localname;
 
 		//get all metadatas declared before Episode tag
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 1114)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java	(revision 1115)
@@ -563,6 +563,7 @@
 		currentText = currentEdition.getText();
 		if (currentPage == null) {
 			System.out.println(EditionUIMessages.bind(EditionUIMessages.warning_no_first_page, currentEdition.getName(), currentText.getName()));
+			return;
 		}
 
 		this.setURL(currentPage.toURL());
Index: tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java
===================================================================
--- tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 1114)
+++ tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java	(revision 1115)
@@ -72,6 +72,7 @@
 import org.eclipse.ui.handlers.IHandlerService;
 import org.txm.edition.rcp.messages.EditionUIMessages;
 import org.txm.objects.Edition;
+import org.txm.objects.Page;
 import org.txm.objects.Text;
 import org.txm.rcp.IImageKeys;
 import org.txm.rcp.editors.IEditionEditor;
@@ -219,8 +220,9 @@
 	 * First page.
 	 */
 	public void firstPage() {
-		for(EditionPanel panel : editionPanels.values())
+		for(EditionPanel panel : editionPanels.values()) {
 			panel.firstPage();
+		}
 		updatePageLabel();
 	}
 
@@ -549,8 +551,9 @@
 			}
 		});
 
-		openEditions(corpus, text, editionNames);
-		firstPage();
+		if (openEditions(corpus, text, editionNames)) {
+			firstPage();
+		}
 	}
 
 	/**
@@ -568,9 +571,13 @@
 	 */
 	private void updatePageLabel() {
 		for (EditionPanel p : editionPanels.values()) {
-			this.setPartName(p.getCurrentPage().getEdition().getText().getName()+ " - "+p.getCurrentPage().getName()); //$NON-NLS-1$
-			page_text.setText(p.getCurrentPage().getName());
-			page_label.setText(" / "+p.getCurrentPage().getEdition().getNumPages()); //$NON-NLS-1$
+			Page cpage = p.getCurrentPage();
+			if (cpage == null) continue;
+			Edition e = cpage.getEdition();
+			if (e == null) continue;
+			this.setPartName(e.getText().getName()+ " - "+cpage.getName()); //$NON-NLS-1$
+			page_text.setText(cpage.getName());
+			page_label.setText(" / "+e.getNumPages()); //$NON-NLS-1$
 			controlsArea.layout();
 			return;
 		}
@@ -589,6 +596,12 @@
 	 */
 	public boolean openEditions(CQPCorpus corpus, Text text, String... editionNames) {
 
+		try {
+			text.compute(null, true);
+		} catch (Exception e) {
+			System.out.println("Error: "+text.getName()+" is not ready to use");
+			return false;
+		}
 		// remove previous EditionPanel
 		for (EditionPanel panel : editionPanels.values()) {
 			panel.dispose();
Index: tmp/org.txm.utils/src/org/txm/utils/StreamHog.java
===================================================================
--- tmp/org.txm.utils/src/org/txm/utils/StreamHog.java	(revision 1114)
+++ tmp/org.txm.utils/src/org/txm/utils/StreamHog.java	(revision 1115)
@@ -28,7 +28,6 @@
 package org.txm.utils;
 
 import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
@@ -104,8 +103,8 @@
 				lastline = line;
 
 			}
-		} catch (IOException e) {
-			System.out.println("ERROR: R logging is broken: "+e);
+		} catch (Exception e) {
+			System.out.println("ERROR: broken process logging : "+e);
 			org.txm.utils.logger.Log.printStackTrace(e);
 		}
 	}
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 1114)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java	(revision 1115)
@@ -278,11 +278,6 @@
 	 * @see org.txm.objects.TxmObject#load()
 	 */
 	protected boolean _load(Element e) {
-		
-		 // partition already persisted
-		if (this.getUUID().length() > 0) {
-			return true;
-		}
 
 		 // partition already computed
 		if (this.hasBeenComputedOnce) {
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 1114)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 1115)
@@ -898,9 +898,9 @@
 					query.getQueryString());
 			queryResult = new QueryResult(queryResultId, queryResultName, this,	query);
 			
-			if (save) {
-				new SavedQuery(this).setParameters(query.toString(), new ArrayList<String>());
-			}
+//			if (save) {
+//				new SavedQuery(this).setParameters(query.toString(), new ArrayList<String>());
+//			}
 		} catch (Exception e) {
 			org.txm.utils.logger.Log.printStackTrace(e);
 			throw new CqiClientException(e);
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 1114)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 1115)
@@ -565,12 +565,12 @@
 		
 		removeFromCWB();
 		
-		File data = new File(getProjectDirectory(), "data");
-		File registry = new File(getProjectDirectory(), "registry");
-		File cqp = new File(getProjectDirectory(), "cqp");
+		File data = new File(getProjectDirectory(), "data/"+this.pID);
+		File registry = new File(getProjectDirectory(), "registry/"+this.pID.toLowerCase());
+		File cqp = new File(getProjectDirectory(), "cqp/"+this.pID+".cqp");
 		DeleteDir.deleteDirectory(data);
-		DeleteDir.deleteDirectory(registry);
-		DeleteDir.deleteDirectory(cqp);
+		registry.delete();
+		cqp.delete();
 	}
 
 	@Override
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java	(revision 1114)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbAlign.java	(revision 1115)
@@ -451,7 +451,7 @@
 	// arg : the align file created by cwb-align
 	{
 		ArrayList<String> args = new ArrayList<String>();
-		args.add(binpath + "cwb-align-encode"); //$NON-NLS-1$
+		args.add(new File(binpath, "cwb-align-encode").getAbsolutePath()); //$NON-NLS-1$
 		if (isd) {
 			args.add("-d"); //$NON-NLS-1$
 			args.add("" + d); //$NON-NLS-1$
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java	(revision 1114)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java	(revision 1115)
@@ -61,6 +61,7 @@
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.rcp.utils.JobHandler;
 import org.txm.rcp.views.corpora.CorporaView;
+import org.txm.searchengine.core.SearchEnginesManager;
 import org.txm.searchengine.cqp.CQPSearchEngine;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.tokenizer.TokenizerClasses;
@@ -170,6 +171,14 @@
 					e.printStackTrace();
 				} finally {
 					System.gc();
+					if (!CQPSearchEngine.isInitialized()) {
+						try {
+							SearchEnginesManager.getCQPSearchEngine().start(monitor);
+						} catch (Exception e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					}
 					syncExec(new Runnable() {
 						@Override
 						public void run() {
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java	(revision 1114)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/ImportSelectedText.java	(revision 1115)
@@ -37,21 +37,17 @@
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Shell;
 import org.txm.Toolbox;
-import org.txm.core.engines.ImportEngine;
-import org.txm.core.engines.ImportEngines;
-import org.txm.core.engines.ScriptedImportEngine;
 import org.txm.core.preferences.TBXPreferences;
 import org.txm.objects.Project;
 import org.txm.rcp.handlers.scripts.ExecuteImportScript;
 import org.txm.rcp.messages.TXMUIMessages;
 import org.txm.searchengine.cqp.corpus.CorpusManager;
 import org.txm.utils.LangDetector;
-// TODO: Auto-generated Javadoc
+
 /**
  * Import the text in the Clipboard as a corpus. the loader used is the
  * QuickLoader 
@@ -76,10 +72,12 @@
 		System.out.println(TXMUIMessages.ImportSelectedText_0);
 
 		try {
-			String corpusName = TXMUIMessages.ImportSelectedText_1+(nextclipcorpus++);
-			while (Toolbox.workspace.getProject(corpusName) != null)
-				corpusName = TXMUIMessages.ImportSelectedText_1+(nextclipcorpus++);
+			String corpusName = TXMUIMessages.ImportSelectedText_1.toUpperCase()+(nextclipcorpus++);
+			while (new File(Toolbox.workspace.getLocation(), corpusName).exists()) {
+				corpusName = TXMUIMessages.ImportSelectedText_1.toUpperCase()+(nextclipcorpus++);
+			}
 			importText(result, corpusName);
+			
 		} catch (Exception e) {
 			// TODO Auto-generated catch block
 			org.txm.rcp.utils.Logger.printStackTrace(e);
@@ -96,7 +94,7 @@
 	 * @throws Exception 
 	 */
 	public static Object importText(String text, String basename) throws Exception {
-				
+		basename = basename.toUpperCase();
 		if (text.length() == 0) {
 			System.err.println(TXMUIMessages.ImportSelectedText_2);
 			return null;
@@ -129,11 +127,15 @@
 		
 		
 		// configure project
-		Project project = new Project(Toolbox.workspace, clipboardDirectory.getName());
+		Project project = Toolbox.workspace.getProject(clipboardDirectory.getName());
+		if (project == null) {	
+			project = new Project(Toolbox.workspace, clipboardDirectory.getName());
+		}
 		project.setSourceDirectory(clipboardDirectory.getAbsolutePath());
 		project.setImportModuleName("txt");
-		project.setEncoding("UTF-8");	
-
+		project.setEncoding("UTF-8");
+		project.getEditionDefinition("default").setBuildEdition(true);
+		
 		String lang = TBXPreferences.getInstance().getString(TBXPreferences.IMPORT_DEFAULT_LANG);
 		if (lang.length() == 0) lang = Locale.getDefault().getLanguage();
 		if ("??".equals(lang)) { //$NON-NLS-1$
@@ -146,7 +148,7 @@
 		
 		project.compute();
 		
-		new ExecuteImportScript().executeScript(project); 
+		ExecuteImportScript.executeScript(project); 
 		return null;
 	}
 }
