Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/importer.groovy	(revision 2998)
@@ -82,7 +82,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File srcDir, File binDir, File txmDir, String basename, String ignoredElements, String lang)
+	public boolean run(File srcDir, File binDir, File txmDir, String basename, String ignoredElements, String lang, def project)
 	{
 		new File(binDir,"tokenized").deleteDir()
 		new File(binDir,"tokenized").mkdir()
@@ -224,6 +224,14 @@
 		cpb.done()
 		okfiles = txmDir.listFiles()
 		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "tokenized").deleteDir()
+			new File(binDir, "ptokenized").deleteDir()
+			new File(binDir, "stokenized").deleteDir()
+			new File(binDir, "src").deleteDir()
+			new File(binDir, "split").deleteDir()
+		}
+		
 		return okfiles != null && okfiles.size() > 0;
 	}
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/xmlLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/xmlLoader.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/xmlLoader.groovy	(revision 2998)
@@ -198,7 +198,7 @@
 
 imp.doTokenize(doTokenizeStep) // change this, to not tokenize xml
 imp.setStopIfMalformed(stopIfMalformed)
-if (!imp.run( srcDir, binDir, txmDir, basename, ignoredElements, lang)) {
+if (!imp.run( srcDir, binDir, txmDir, basename, ignoredElements, lang, project)) {
 	println "import process stopped"
 	return
 }
@@ -240,6 +240,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy	(revision 2998)
@@ -716,6 +716,10 @@
 			cwbMa.run(corpusname, outDir + "/registry");
 		} catch (Exception ex) {System.out.println(ex); return false;}
 
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy	(revision 2998)
@@ -960,7 +960,11 @@
 			}
 			cwbMa.run(corpusname, outDir + "/registry");
 		} catch (Exception ex) {System.out.println(ex);return false;}
-
+
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/bfmLoader.groovy	(revision 2998)
@@ -125,7 +125,7 @@
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 println "-- IMPORTER - Reading source files"
 def imp = new importer()
-if (!imp.run(srcDir, binDir, txmDir, basename, metadataXPath)) {
+if (!imp.run(srcDir, binDir, txmDir, basename, metadataXPath, project)) {
 	println "import process stopped";
 	return;
 }
@@ -139,6 +139,12 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotate_status = true;
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/importer.groovy	(revision 2998)
@@ -64,7 +64,7 @@
  */
 class importer {
 	
-	public boolean run(File srcDir, File binDir, File txmDir, String basename, Properties metadataXPath)
+	public boolean run(File srcDir, File binDir, File txmDir, String basename, Properties metadataXPath, def project)
 	{
 		new File(binDir, "ptokenized").deleteDir();
 		new File(binDir, "ptokenized").mkdir();
@@ -253,6 +253,12 @@
 			}
 		}
 		println("")
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "tokenized").deleteDir()
+			new File(binDir, "stokenized").deleteDir()
+			new File(binDir, "headers").deleteDir()
+		}
 		return true;
 	}
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/docLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/docLoader.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/docLoader.groovy	(revision 2998)
@@ -217,7 +217,7 @@
 def imp = new importer();
 imp.doValidation(true) // change this to not validate xml
 imp.doTokenize(true) // change this, to not tokenize xml
-if (!imp.run(srcDir, binDir, txmDir, basename, "", lang)) {
+if (!imp.run(srcDir, binDir, txmDir, basename, "", lang, project)) {
 	println "import process stopped";
 	return;
 }
@@ -260,6 +260,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy	(revision 2998)
@@ -640,6 +640,10 @@
 				}
 			}
 		}
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
 
 		return true;
 	}
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/tmxLoader.groovy	(revision 2998)
@@ -81,7 +81,7 @@
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "IMPORTER - Reading source files");
 def imp = new importer()
-imp.run(srcDir, binDir, txmDir, textLangs, langGroups);
+imp.run(srcDir, binDir, txmDir, textLangs, langGroups, project);
 def corpusIDS = imp.getCorpusIDS()
 
 if (MONITOR != null) MONITOR.worked(20, "ANNOTATE - Running NLP tools");
@@ -90,6 +90,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 println "langs : "+textLangs
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/importer.groovy	(revision 2998)
@@ -67,7 +67,7 @@
 	 * @param rootDirFile the root dir file
 	 * @param base the base
 	 */
-	public static void run(File srcDir, File binDir, File txmDir, HashMap<String, String> langs, HashMap<String, String> originalTexts)
+	public static void run(File srcDir, File binDir, File txmDir, HashMap<String, String> langs, HashMap<String, String> originalTexts, def project)
 	{
 		String filename = binDir.getName();
 		
@@ -142,6 +142,14 @@
 			}
 		}
 		println ""
+		
+		if (project.getCleanAfterBuild()) {
+			new File(project.getProjectDirectory(), "tokenized").deleteDir()
+			new File(project.getProjectDirectory(), "ptokenized").deleteDir()
+			new File(project.getProjectDirectory(), "stokenized").deleteDir()
+			new File(project.getProjectDirectory(), "src").deleteDir()
+			new File(project.getProjectDirectory(), "split").deleteDir()
+		}
 	}
 	
 	public def getCorpusIDS() {
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivaLoader.groovy	(revision 2998)
@@ -178,7 +178,7 @@
 imp.doValidation(true) // change this to not validate xml
 imp.doTokenize(true) // change this, to not tokenize xml
 imp.setStopIfMalformed(stopIfMalformed);
-if (!imp.run( srcDir, binDir, txmDir, basename, null, lang)) {
+if (!imp.run( srcDir, binDir, txmDir, basename, null, lang, project)) {
 	println "import process stopped";
 	return;
 }
@@ -218,6 +218,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy	(revision 2998)
@@ -84,7 +84,7 @@
 
 	String lang; // language used by the tokenizer
 	
-	Project corpusProject;
+	Project project;
 
 	/**
 	 * Instantiates a new importer.
@@ -93,13 +93,13 @@
 	 * @param outdir the outdir
 	 * @param metadatas the metadatas
 	 */
-	public importer(ArrayList<File> trsfiles, File binDir, File txmDir, Metadatas metadatas, lang, Project corpusProject) {
+	public importer(ArrayList<File> trsfiles, File binDir, File txmDir, Metadatas metadatas, lang, Project project) {
 		this.trsfiles = trsfiles;
 		this.txmDir = txmDir;
 		this.binDir = binDir;
 		this.metadatas = metadatas;
 		this.lang = lang;
-		this.corpusProject = corpusProject;
+		this.project = project;
 	}
 
 	/**
@@ -247,11 +247,10 @@
 			}
 		}
 
-		String cleanDirectories = corpusProject.getCleanAfterBuild();
-		if ("true".equals(cleanDirectories)) {
-			new File(corpusProject.getProjectDirectory(), "tokenized").deleteDir()
-			new File(corpusProject.getProjectDirectory(), "src").deleteDir()
-			new File(corpusProject.getProjectDirectory(), "split").deleteDir()
+		if (project.getCleanAfterBuild()) {
+			new File(project.getProjectDirectory(), "tokenized").deleteDir()
+			new File(project.getProjectDirectory(), "src").deleteDir()
+			new File(project.getProjectDirectory(), "split").deleteDir()
 		}
 		
 		cpb.done()
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy	(revision 2998)
@@ -67,28 +67,28 @@
 String userDir = System.getProperty("user.home");
 
 def MONITOR;
-Project corpusProject;
+Project project;
 
-try {corpusProject=projectBinding;MONITOR=monitor} catch (Exception)
+try {project=projectBinding;MONITOR=monitor} catch (Exception)
 {	}
-if (corpusProject == null) { println "no project set. Aborting"; return; }
+if (project == null) { println "no project set. Aborting"; return; }
 
-String corpusname = corpusProject.getName();
+String corpusname = project.getName();
 String basename = corpusname
-String rootDir = corpusProject.getSrcdir();
-String lang = corpusProject.getLang()
+String rootDir = project.getSrcdir();
+String lang = project.getLang()
 String model = lang
-String encoding = corpusProject.getEncoding()
-boolean annotate = corpusProject.getAnnotate()
-String xsl = corpusProject.getFrontXSL();
-def xslParams = corpusProject.getXsltParameters();
-int wordsPerPage = corpusProject.getEditionDefinition("default").getWordsPerPage()
-String page_element = corpusProject.getEditionDefinition("default").getPageElement()
-boolean build_edition = corpusProject.getEditionDefinition("default").getBuildEdition()
-boolean update = corpusProject.getDoUpdate()
+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()
+boolean update = project.getDoUpdate()
 
 File srcDir = new File(rootDir);
-File binDir = corpusProject.getProjectDirectory();
+File binDir = project.getProjectDirectory();
 binDir.mkdirs();
 if (!binDir.exists()) {
 	println "Could not create binDir "+binDir
@@ -195,7 +195,7 @@
 		if (MONITOR != null) MONITOR.worked(1, "IMPORTER")
 		if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 		println "-- IMPORTER"
-		def imp = new importer(trsfiles, binDir, txmDir, metadatas, lang, corpusProject) //put result in the txm folder of binDir
+		def imp = new importer(trsfiles, binDir, txmDir, metadatas, lang, project) //put result in the txm folder of binDir
 		if (!imp.run()) {
 			println "Failed to prepare files - Aborting";
 			return;
@@ -243,11 +243,10 @@
 			if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 				annotationSuccess = true;
 				
-				String cleanDirectories = corpusProject.getCleanAfterBuild();
-				if ("true".equals(cleanDirectories)) {
-					new File(corpusProject.getProjectDirectory(), "ptreetagger").deleteDir()
-					new File(corpusProject.getProjectDirectory(), "treetagger").deleteDir()
-					new File(corpusProject.getProjectDirectory(), "annotations").deleteDir()
+				if (project.getCleanAfterBuild()) {
+					new File(binDir, "treetagger").deleteDir()
+					new File(binDir, "ptreetagger").deleteDir()
+					new File(binDir, "annotations").deleteDir()
 				}
 			}
 		}
@@ -284,7 +283,7 @@
 	if(debug) comp.setDebug();
 	comp.removeInterviewers(removeInterviewer);
 	comp.setIgnoreTranscriberMetadata(ignoreTranscriberMetadata);
-	if (!comp.run(corpusProject, xmltxmFiles, corpusname, "default", binDir)) {
+	if (!comp.run(project, xmltxmFiles, corpusname, "default", binDir)) {
 		println "Failed to compile files";
 		return;
 	}
@@ -312,9 +311,9 @@
 			List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang);
 			List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang);
 
-			Text t = corpusProject.getText(txtname)
+			Text t = project.getText(txtname)
 			if (t == null) {
-				t = new Text(corpusProject);
+				t = new Text(project);
 				t.setName(txtname);
 			}
 			t.setSourceFile(txmFile)
@@ -356,10 +355,10 @@
 			String txtname = txmFile.getName();
 			int i = txtname.lastIndexOf(".");
 			if(i > 0) txtname = txtname.substring(0, i);
-			File mediaFile = new File(corpusProject.getSrcdir(), txtname + ".mp3")
-			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".wav")
-			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".mp4")
-			if (!mediaFile.exists()) mediaFile = new File(corpusProject.getSrcdir(), txtname + ".avi")
+			File mediaFile = new File(project.getSrcdir(), txtname + ".mp3")
+			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".wav")
+			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".mp4")
+			if (!mediaFile.exists()) mediaFile = new File(project.getSrcdir(), txtname + ".avi")
 
 			if (mediaFile.exists()) {
 				File copy = new File(binDir, "media/"+mediaFile.getName())
@@ -374,4 +373,4 @@
 
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "FINALIZING")
-readyToLoad = corpusProject.save();
+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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy	(revision 2998)
@@ -117,7 +117,7 @@
 	 * @param outdir the outdir
 	 * @return true, if successful
 	 */
-	public boolean run(Project corpusProject, List<File> xmlfiles, String corpusname, String projectname, File binDir) {
+	public boolean run(Project project, List<File> xmlfiles, String corpusname, String projectname, File binDir) {
 		
 		//println "run compiler with $xmlfiles, $basename and $outdir"
 		this.outdir = binDir;
@@ -129,17 +129,17 @@
 
 		sectionAttrs = new HashSet<String>() // reset section attributs set
 
-		CorpusBuild corpus = corpusProject.getCorpusBuild(corpusProject.getName(), MainCorpus.class);
+		CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
 		if (corpus != null) {
-			if (corpusProject.getDoUpdate()) {
+			if (project.getDoUpdate()) {
 				corpus.clean(); // remove old files
 			} else {
 				corpus.delete(); // remove old files and TXMResult children
 			}
 		} else {
-			corpus = new MainCorpus(corpusProject);
-			corpus.setID(corpusProject.getName());
-			corpus.setName(corpusProject.getName());
+			corpus = new MainCorpus(project);
+			corpus.setID(project.getName());
+			corpus.setName(project.getName());
 		}
 		corpus.setDescription("Built with the XML-TRS import module");
 		
@@ -236,9 +236,8 @@
 
 		} catch (Exception ex) {System.out.println(ex); return false;}
 
-		String cleanDirectories = corpusProject.getCleanAfterBuild();
-		if ("true".equals(cleanDirectories)) {
-			new File(corpusProject.getProjectDirectory(), "cqp").deleteDir()
+		if (project.getCleanAfterBuild()) {
+			new File(project.getProjectDirectory(), "cqp").deleteDir()
 		}
 		
 		return true;
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/TRSToTEI.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/TRSToTEI.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/TRSToTEI.groovy	(revision 2998)
@@ -206,10 +206,9 @@
 				writer.writeAttribute("time", formatedTime)
 				
 				writer.writeAttribute("start", time)
-				writer.writeAttribute("end", parser.getAttributeValue(null, "endTime"))
+				writer.writeAttribute("end", ""+parser.getAttributeValue(null, "endTime"))
+				writer.writeAttribute("who", ""+parser.getAttributeValue(null, "speaker"))
 				
-				writer.writeAttribute("who", parser.getAttributeValue(null, "speaker"))
-				
 				for (int i = 0; i < parser.getAttributeCount(); i++) { // write other attributes if any
 					String v = parser.getAttributeLocalName(i);
 					if (!("who".equals(v)) && !("overlap".equals(v)) && !("time".equals(v)) && !("speaker".equals(v)) && !("endTime".equals(v)) && !("startTime".equals(v))) {
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/importer.groovy	(revision 2998)
@@ -56,7 +56,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public static boolean run(File srcDir, File binDir, File txmDir, String encoding, List<String> suffixes, String basename, String lang) {
+	public static boolean run(File srcDir, File binDir, File txmDir, String encoding, List<String> suffixes, String basename, String lang, def project) {
 		
 		File stokenizedDir = new File(binDir,"stokenized");
 		stokenizedDir.deleteDir();
@@ -297,6 +297,14 @@
 		files = txmDir.listFiles()
 		if (files == null || files.size() == 0) return false
 		
+		if (project.getCleanAfterBuild()) {
+			new File(project.getProjectDirectory(), "tokenized").deleteDir()
+			new File(project.getProjectDirectory(), "ptokenized").deleteDir()
+			new File(project.getProjectDirectory(), "stokenized").deleteDir()
+			new File(project.getProjectDirectory(), "src").deleteDir()
+			new File(project.getProjectDirectory(), "split").deleteDir()
+		}
+		
 		return true;
 	}
 }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/txtLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/txtLoader.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/txtLoader.groovy	(revision 2998)
@@ -98,7 +98,7 @@
 println "-- IMPORTER - Reading source files with extension "+suffixes
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 if (MONITOR != null) MONITOR.worked(20, "IMPORTER - Reading source files with extension "+suffixes)
-if (!new importer().run(srcDir, binDir, txmDir,encoding, suffixes, basename, lang)) {
+if (!new importer().run(srcDir, binDir, txmDir,encoding, suffixes, basename, lang, project)) {
 	println "Import process stopped";
 	return;
 }
@@ -136,6 +136,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy	(revision 2998)
@@ -267,6 +267,10 @@
 			cwbMa.run(corpusname, outDir + "/registry");
 		} catch (Exception ex) {System.out.println("CWB error: "+ex); return false;}
 		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 	
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/importer.groovy	(revision 2998)
@@ -68,7 +68,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public static boolean run(File rootDirFile, File binDir, File txmDir, String encoding, String basename, String lang)
+	public static boolean run(File rootDirFile, File binDir, File txmDir, String encoding, String basename, String lang, def project)
 	{
 		if (rootDirFile.listFiles() == null || rootDirFile.listFiles().size() == 0) {
 			println "Error: no file to process in "+rootDirFile;
@@ -184,6 +184,13 @@
 			}
 		}
 		cpb.done()
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "tokenized").deleteDir()
+			new File(binDir, "stokenized").deleteDir()
+			new File(binDir, "src").deleteDir()
+			new File(binDir, "split").deleteDir()
+		}
 		return true;
 	}
 }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/alcesteLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/alcesteLoader.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/alcesteLoader.groovy	(revision 2998)
@@ -78,7 +78,7 @@
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 println "-- IMPORTER - Reading source files"
 
-if (!(new importer().run(srcDir, binDir, txmDir, encoding, basename, lang))) {
+if (!(new importer().run(srcDir, binDir, txmDir, encoding, basename, lang, project))) {
 	println "import process stopped";
 	return;
 }
@@ -94,6 +94,12 @@
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
 	}
+	
+	if (project.getCleanAfterBuild()) {
+		new File(binDir, "treetagger").deleteDir()
+		new File(binDir, "ptreetagger").deleteDir()
+		new File(binDir, "annotations").deleteDir()
+	}
 }
 
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy	(revision 2998)
@@ -246,6 +246,10 @@
 			
 		} catch (Exception ex) {System.out.println(ex); return false;}
 
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 	
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/hyperbaseLoader.groovy	(revision 2998)
@@ -91,6 +91,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotationSuccess = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy	(revision 2998)
@@ -248,6 +248,10 @@
 			
 		} catch (Exception ex) {System.out.println(ex); return false;}
 		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 	
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy	(revision 2998)
@@ -186,7 +186,11 @@
 			cwbMa.run(corpusname, outDir + "/registry");
 			return true;
 		} catch (Exception ex) {System.out.println(ex); return false;}
-
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy	(revision 2998)
@@ -93,7 +93,8 @@
 		if (!doCWBEncodeStep()) return;
 		if (!doCWBMakeAllStep()) return;
 
-		if (module.getProject().getCleanAfterBuild() && !module.getProject().getDoUpdate()) {
+		if (module.getProject().getCleanAfterBuild() 
+			&& !module.getProject().getDoUpdate()) { // for optimization purpose, don't clean the CQP files
 			new File(module.getBinaryDirectory(), "cqp").deleteDir()
 		}
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/TTAnnotater.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/TTAnnotater.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/TTAnnotater.groovy	(revision 2998)
@@ -45,6 +45,7 @@
 		
 		if (cleanDirectories) {
 			new File(module.getBinaryDirectory(), "treetagger").deleteDir()
+			new File(module.getBinaryDirectory(), "ptreetagger").deleteDir()
 			new File(module.getBinaryDirectory(), "annotations").deleteDir()
 		}
 		
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy	(revision 2998)
@@ -139,8 +139,7 @@
 		
 		isSuccessFul = filesToProcess.size() > 0
 		
-		String cleanDirectories = project.getCleanAfterBuild();
-		if ("true".equals(cleanDirectories)) {
+		if (project.getCleanAfterBuild()) {
 			new File(module.getBinaryDirectory(), "tokenized").deleteDir()
 			new File(module.getBinaryDirectory(), "src").deleteDir()
 			new File(module.getBinaryDirectory(), "split").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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy	(revision 2998)
@@ -472,6 +472,10 @@
 			ex.printStackTrace();
 			return false;
 		}
+		
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
 
 		return true;
 	}
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy	(revision 2998)
@@ -245,6 +245,10 @@
 
 		} catch (Exception ex) { System.err.println(ex); return false;}
 
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "cqp").deleteDir()
+		}
+		
 		return true;
 	}
 
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/importer.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/importer.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/importer.groovy	(revision 2998)
@@ -70,7 +70,7 @@
 	 * @param basename the basename
 	 * @return true, if successful
 	 */
-	public boolean run(File srcDir, File binDir, File txmDir, String encoding, String basename)
+	public boolean run(File srcDir, File binDir, File txmDir, String encoding, String basename, def project)
 	{
 		String rootDir = srcDir.getAbsolutePath()+"/"
 		// scanning directory brut/*.cnr
@@ -262,6 +262,14 @@
 			} else print "."
 		}
 		println ""
+		
+		if (project.getCleanAfterBuild()) {
+			new File(project.getProjectDirectory(), "tokenized").deleteDir()
+			new File(project.getProjectDirectory(), "ptokenized").deleteDir()
+			new File(project.getProjectDirectory(), "stokenized").deleteDir()
+			new File(project.getProjectDirectory(), "src").deleteDir()
+			new File(project.getProjectDirectory(), "split").deleteDir()
+		}
 		return true;
 	}
 
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 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/discoursLoader.groovy	(revision 2998)
@@ -75,7 +75,7 @@
 if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
 println "-- IMPORTER - Reading source files"
 def imp = new importer();
-if (!imp.run(srcDir, binDir, txmDir, encoding, basename)) {
+if (!imp.run(srcDir, binDir, txmDir, encoding, basename, project)) {
 	println "import process stopped";
 	return;
 }
Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/frantext/frantextLoader.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/frantext/frantextLoader.groovy	(revision 2997)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/frantext/frantextLoader.groovy	(revision 2998)
@@ -159,6 +159,11 @@
 	def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
 	if (engine.processDirectory(txmDir, binDir, ["lang":model])) {
 		annotate_status = true;
+		if (project.getCleanAfterBuild()) {
+			new File(binDir, "treetagger").deleteDir()
+			new File(binDir, "ptreetagger").deleteDir()
+			new File(binDir, "annotations").deleteDir()
+		}
 	}
 }
 
