Index: tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy
===================================================================
--- tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy	(revision 2074)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy	(revision 2075)
@@ -163,10 +163,13 @@
 		boolean mustBuildFacsEdition = project.getEditionDefinition("facs").getBuildEdition()
 		if (!mustBuildFacsEdition) return true;
 
-		String imageDirectoryPath = project.getEditionDefinition("facs").getImagesDirectory().trim();
-		File imageDirectory = new File(imageDirectoryPath);
-		if (!imageDirectoryPath.startsWith("http") && imageDirectoryPath.length()== 0 && !imageDirectory.exists() && !imageDirectory.isDirectory()) {
-			imageDirectory = null;
+		String imageDirectoryPath = project.getEditionDefinition("facs").getImagesDirectory();
+		if (imageDirectoryPath != null) {
+			imageDirectoryPath = imageDirectoryPath.trim()
+			File imageDirectory = new File(imageDirectoryPath);
+			if (!imageDirectoryPath.startsWith("http") && imageDirectoryPath.length()== 0 && !imageDirectory.exists() && !imageDirectory.isDirectory()) {
+				imageDirectory = null;
+			}
 		}
 
 		def second = 0
Index: tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 2074)
+++ tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 2075)
@@ -148,6 +148,8 @@
 		
 		preferences.putBoolean(TBXPreferences.EXPERT_USER, false);
 		preferences.putBoolean(TBXPreferences.VISIBLE, true);
+		preferences.putBoolean(TBXPreferences.CLEAN, true);
+		
 
 		// FIXME
 		preferences.putBoolean(TBXPreferences.ADD_TECH_LOGS, true);
Index: tmp/org.txm.treetagger.rcp/src/org/txm/treetagger/rcp/handlers/Train.java
===================================================================
--- tmp/org.txm.treetagger.rcp/src/org/txm/treetagger/rcp/handlers/Train.java	(revision 2074)
+++ tmp/org.txm.treetagger.rcp/src/org/txm/treetagger/rcp/handlers/Train.java	(revision 2075)
@@ -66,6 +66,8 @@
 	public String lemmaProperty = null;
 	@Option(name="lexique", usage="Lexicon file", widget="File", required=true, def="lexicon.txt")
 	public File lexique = null;
+	@Option(name="openclassfile", usage="openclassfile file", widget="File", required=true, def="")
+	public File openclassfile = null;
 	@Option(name="options", usage="TreeTagger supplementary options", widget="String", required=true, def="")
 	public String options = null;
 
@@ -85,7 +87,7 @@
 				corpus = (CQPCorpus)first;
 				if (ParametersDialog.open(this)) {
 
-					train(corpus, model, lexique, new String[]{posProperty, lemmaProperty}, sentenceTag, options.split("  "));
+					train(corpus, model, lexique, openclassfile, new String[]{posProperty, lemmaProperty}, sentenceTag, options.split("  "));
 
 					return corpus;
 				}
@@ -96,7 +98,7 @@
 		return null;
 	}
 
-	public static void train(final CQPCorpus corpus, final File model, final File lexique, final String[] properties, final String sentenceTag, final String[] options) {
+	public static void train(final CQPCorpus corpus, final File model, final File lexique, final File openclassfile, final String[] properties, final String sentenceTag, final String[] options) {
 
 		JobHandler job = new JobHandler("Applying TreeTagger to "+corpus+" corpus.") {
 			@Override
@@ -106,7 +108,7 @@
 					File lexique2 = lexique;
 					MainCorpus mainCorpus = corpus.getMainCorpus();
 					File corpusBinaryDirectory = mainCorpus.getProjectDirectory();
-					
+
 					System.out.println("TRAIN : "+corpus+" with "+lexique2+" to create "+model+ " with properties "+Arrays.toString(properties));
 
 					if (properties == null || properties.length != 2) {
@@ -121,15 +123,15 @@
 							return Status.CANCEL_STATUS;
 						}
 					}
-					
+
 					Property pos = corpus.getProperty(properties[0]);
 					Property lemma = corpus.getProperty(properties[1]);
-					
+
 					// Prepare temporary directory
 					File treetaggerSrcDirectory = new File(mainCorpus.getProjectDirectory(), "treetagger");
 					DeleteDir.deleteDirectory(treetaggerSrcDirectory);
 					treetaggerSrcDirectory.mkdirs();
-					
+
 					HashMap<String, HashSet<String>> simplified_lexicon = null;
 					HashMap<String, HashSet<String>> simplified_lexicon_errors = null;
 					int error_counter = 0;
@@ -160,7 +162,7 @@
 							if (!lex.containsKey(form)) {
 								ArrayList<String> pairs = new ArrayList<String>();
 								HashSet<String> posValues = new HashSet<String>();
-								
+
 								allPosValues.put(form, posValues);
 								lex.put(form, pairs);
 							}
@@ -169,7 +171,7 @@
 							String posValue = values.get(1).get(0);
 							String lemmaValue = values.get(2).get(0);
 							if (posValues.contains(posValue)) {
-								
+
 							} else {
 								posValues.add(posValue);
 								pairs.add(posValue);
@@ -185,7 +187,7 @@
 							for (String v : lex.get(form)) {
 								if (tab) writer.write("\t"+v);
 								else writer.write(" "+v);
-								
+
 								tab = !tab;
 							}
 							writer.write("\n");
@@ -209,10 +211,10 @@
 						}
 						reader.close();
 					}
-					
-					
+
+
 					// create TT SRC file from CWB indexes
-					
+
 					File ttSrcFile = new File(treetaggerSrcDirectory, mainCorpus.getID()+".tt");
 					System.out.println("TT SRC file: "+ttSrcFile.getAbsolutePath());
 					BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(ttSrcFile));
@@ -223,7 +225,7 @@
 					for (Match m : corpus.getMatches()) {
 						for (int i = m.getStart() ; i <= m.getEnd() ; i++) { // end match must be included
 							positions.add(i);
-							
+
 							if (positions.size() >= 1000) { // avoid too big array
 								int[] positions_array = new int[positions.size()];
 								int ip = 0;
@@ -236,7 +238,7 @@
 									if (w != null) {
 										String s = w+"\t"+values[iW];
 										ps.println(s);
-										
+
 										if (simplified_lexicon != null) { // check given lexicon
 											if (simplified_lexicon.containsKey(w)) {
 												if (!simplified_lexicon.get(w).contains(values[iW])) {
@@ -277,7 +279,7 @@
 						positions.clear();
 					}
 					ps.close();
-					
+
 					if (simplified_lexicon_errors != null && simplified_lexicon_errors.size() > 0) {
 						File error_file = new File(treetaggerSrcDirectory, "errors.txt");
 						PrintWriter errorwriter = IOUtils.getWriter(error_file);
@@ -300,7 +302,7 @@
 						String line = reader.readLine();
 						while (line != null) {
 							String w = line.split("\t", 2)[0];
-							
+
 							if (simplified_lexicon_errors.containsKey(w)) {
 								for (String p : simplified_lexicon_errors.get(w)) {
 									if (!p.startsWith("#"))
@@ -308,11 +310,11 @@
 								}
 								simplified_lexicon_errors.remove(w);
 							}
-							
+
 							writer.println(line);
 							line = reader.readLine();
 						}
-						
+
 						// write missing words
 						for (String w2 : simplified_lexicon_errors.keySet()) {
 							writer.print(w2);
@@ -321,34 +323,37 @@
 							}
 							writer.println("");
 						}
-						
+
 						reader.close();
 						writer.close();
 						System.out.println("Adding words to a temporary lexicon: "+lexique3);
 						lexique2 = lexique3;
 					}
-					
+
 					// Create open class file : contains all pos values
-					File openclassfile = new File(treetaggerSrcDirectory, "openclasses.txt");
-					PrintWriter openClassFileWriter = IOUtils.getWriter(openclassfile);
-					
-//					Lexicon poslexicon = corpus.getLexicon(pos);
-//					String[] posValues = poslexicon.getForms();
-//					for (int iV = 0 ; iV < posValues.length ; iV++) {
-//						if (iV == 0) openClassFileWriter.print(posValues[iV]);
-//						else openClassFileWriter.print(" "+posValues[iV]);
-//					}
-					openClassFileWriter.close();
+					File tmpopenclassfile = openclassfile;
+					if (tmpopenclassfile == null || tmpopenclassfile.getName().length() ==0) {
+						tmpopenclassfile = new File(treetaggerSrcDirectory, "openclasses.txt");
+						PrintWriter openClassFileWriter = IOUtils.getWriter(openclassfile);
 
+						//					Lexicon poslexicon = corpus.getLexicon(pos);
+						//					String[] posValues = poslexicon.getForms();
+						//					for (int iV = 0 ; iV < posValues.length ; iV++) {
+						//						if (iV == 0) openClassFileWriter.print(posValues[iV]);
+						//						else openClassFileWriter.print(" "+posValues[iV]);
+						//					}
+						openClassFileWriter.close();
+					}
+
 					// Call treetagger-train
-					if (ttSrcFile.exists() && lexique2.exists() && openclassfile.exists()) {
+					if (ttSrcFile.exists() && lexique2.exists() && tmpopenclassfile.exists()) {
 						System.out.println("Running treetagger-train...");
 						String treetaggerBinDirectory = new File(TreeTaggerPreferences.getInstance().getString(TreeTaggerPreferences.INSTALL_PATH), "bin").getAbsolutePath();
 						if (!treetaggerBinDirectory.endsWith("/")) treetaggerBinDirectory += "/";
 
 						TreeTagger tt = new TreeTagger(treetaggerBinDirectory, options);
 						tt.settoken();
-						
+
 						//tt.setlemma();
 						tt.setsgml();
 						tt.setst(sentenceTag);
@@ -358,45 +363,45 @@
 						if (cl > 0) {
 							tt.setcl(cl);
 						}
-						
+
 						float dtg = TreeTaggerPreferences.getInstance().getFloat(TreeTaggerPreferences.OPTIONS_DTG);
 						if (dtg > 0) {
 							tt.setdtg(dtg);
 						}
-						
+
 						float sw = TreeTaggerPreferences.getInstance().getFloat(TreeTaggerPreferences.OPTIONS_SW);
 						if (sw > 0) {
 							tt.setsw(sw);
 						}
-						
+
 						float atg = TreeTaggerPreferences.getInstance().getFloat(TreeTaggerPreferences.OPTIONS_ATG);
 						if (atg > 0) {
 							tt.setatg(atg);
 						}
-						
+
 						float ecw = TreeTaggerPreferences.getInstance().getFloat(TreeTaggerPreferences.OPTIONS_ECW);
 						if (ecw > 0) {
 							tt.setecw(ecw);
 						}
-						
+
 						float lt = TreeTaggerPreferences.getInstance().getFloat(TreeTaggerPreferences.OPTIONS_LT);
 						if (lt > 0) {
 							tt.setlt(lt);
 						}
-						
+
 						if (TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.OPTIONS_DEBUG)) {
 							tt.debug(true);
 						} else {
 							tt.setquiet();
 						}
-						
-						tt.traintreetagger(lexique2.getAbsolutePath(), openclassfile.getAbsolutePath(), ttSrcFile.getAbsolutePath(), model.getAbsolutePath());
-						
+
+						tt.traintreetagger(lexique2.getAbsolutePath(), tmpopenclassfile.getAbsolutePath(), ttSrcFile.getAbsolutePath(), model.getAbsolutePath());
+
 						System.out.println("Done: "+model.getAbsolutePath());
 					} else {
 						System.out.println("Aborting.");
 					}
-					
+
 					return Status.OK_STATUS;
 				} catch (Exception e) {
 					System.out.println("Error while training TT: "+e);
