Index: tmp/org.txm.analec.rcp/src/org/txm/macro/urs/democrat/BuildDemocratCorpusVersion1Macro.groovy
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/macro/urs/democrat/BuildDemocratCorpusVersion1Macro.groovy	(revision 2076)
+++ tmp/org.txm.analec.rcp/src/org/txm/macro/urs/democrat/BuildDemocratCorpusVersion1Macro.groovy	(revision 2077)
@@ -121,7 +121,7 @@
 	if (corpus == null) {
 		File binCorpusFile = new File(inputDirectory, txm_file)
 		if (!binCorpusFile.exists()) {
-			println " ** no corpus binary file found for ID=$corpus_id : $binCorpusFile"
+			println " ** no corpus binary file found for ID='$corpus_id' : $binCorpusFile"
 			continue;
 		}
 		println " loading corpus from ${binCorpusFile}..."
@@ -129,6 +129,10 @@
 		job.join();
 		project = job.getResultObject();
 		corpus = project.getCorpusBuild(corpus_id);
+		if (corpus == null) {
+			println " ** no corpus for ID='$corpus_id' found in the binary corpus."
+			conitnue
+		}
 		corpora[corpus.getID()] = corpus;
 		loaded = true
 	} else {
Index: tmp/org.txm.analec.rcp/src/org/txm/macro/urs/export/ExportAsMacro.groovy
===================================================================
--- tmp/org.txm.analec.rcp/src/org/txm/macro/urs/export/ExportAsMacro.groovy	(revision 2076)
+++ tmp/org.txm.analec.rcp/src/org/txm/macro/urs/export/ExportAsMacro.groovy	(revision 2077)
@@ -98,15 +98,12 @@
 println "renaming $txmFile : "+txmFile.renameTo(txmFile2)
 
 // patch name in settings
-println "replacing old name $name ->  ${new_name}"
-String node = mainCorpus.getProject().getParametersNodePath()
-node = node.substring(node.lastIndexOf("/"))
-File projectPrefs = new File(newBinDirectory, ".settings/"+node+".prefs")
-node = mainCorpus.getParametersNodePath()
-node = node.substring(node.lastIndexOf("/"))
-File maincorpusPrefs = new File(newBinDirectory, ".settings/"+node+".prefs")
-IOUtils.write(projectPrefs, projectPrefs.getText().replace(name, new_name))
-IOUtils.write(maincorpusPrefs, maincorpusPrefs.getText().replace(name, new_name))
+println "replacing old name $name ->  ${new_name} in preferences"
+File settingsDirectory = new File(newBinDirectory, ".settings")
+for (File prefFile : settingsDirectory.listFiles()) {
+	IOUtils.write(prefFile, prefFile.getText().replace(name, new_name))
+}
+
 File projectSetting = new File(newBinDirectory, ".project")
 IOUtils.write(projectSetting, projectSetting.getText().replace(name, new_name))
 
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 2076)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy	(revision 2077)
@@ -427,7 +427,7 @@
 					outfile.delete(); // fail
 				}
 			}
-			println ""
+			cpb.done()
 		}
 		return true;
 	}
@@ -469,7 +469,7 @@
 			}
 		}
 		filesToProcess = outputDirectory.listFiles();
-		println ""
+		cpb.done();
 		return true;
 	}
 
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 2076)
+++ tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy	(revision 2077)
@@ -224,6 +224,7 @@
 								foundtei = false;
 								break;
 							case "text":
+								output.write("</text>\n");
 								foundtext = false;
 								break;
 							case FORM:
Index: tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java
===================================================================
--- tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java	(revision 2076)
+++ tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java	(revision 2077)
@@ -165,31 +165,36 @@
 		Project p = Toolbox.workspace.getProject(basedirname);
 
 		if (corpusdir.exists() || p != null) {
-			boolean b = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), TXMUIMessages.warning, NLS.bind(TXMUIMessages.theP0CorpusDirectoryAlreadyExistsDoYouWantToReplaceIt, corpusdir.getName().toUpperCase()));
-			if (b) {
-				//TODO: to enable backup of binary corpus I need to be able to reload correctly a corpus in CQP corpus manager
-				//				backup = new File(corpusdir.getParentFile(), corpusdir.getName()+"-back"); //$NON-NLS-1$
-				//				DeleteDir.deleteDirectory(backup);
-				//				if (backup.exists()) {
-				//					System.out.println(Messages.LoadBinaryCorpus_1+backup);
-				//					return false;
-				//				}
-				//				if (!corpusdir.renameTo(backup)) {
-				//					System.out.println(Messages.LoadBinaryCorpus_2+backup);
-				//					return false;
-				//				}
+			if (Display.getCurrent() == null) { // not a UI thread -> delete the previous corpus
+				p.delete(); // the user said yes, so delete the previous project
+			} else {
 
-				if (p != null) {
-					p.delete(); // the user said yes, so delete the previous project
+				boolean b = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), TXMUIMessages.warning, NLS.bind(TXMUIMessages.theP0CorpusDirectoryAlreadyExistsDoYouWantToReplaceIt, corpusdir.getName().toUpperCase()));
+				if (b) {
+					//TODO: to enable backup of binary corpus I need to be able to reload correctly a corpus in CQP corpus manager
+					//				backup = new File(corpusdir.getParentFile(), corpusdir.getName()+"-back"); //$NON-NLS-1$
+					//				DeleteDir.deleteDirectory(backup);
+					//				if (backup.exists()) {
+					//					System.out.println(Messages.LoadBinaryCorpus_1+backup);
+					//					return false;
+					//				}
+					//				if (!corpusdir.renameTo(backup)) {
+					//					System.out.println(Messages.LoadBinaryCorpus_2+backup);
+					//					return false;
+					//				}
+
+					if (p != null) {
+						p.delete(); // the user said yes, so delete the previous project
+					} else {
+						DeleteDir.deleteDirectory(corpusdir);
+					}
+
+					if (corpusdir.exists()) {
+						return null;
+					}
 				} else {
-					DeleteDir.deleteDirectory(corpusdir);
+					return null; // abandon
 				}
-
-				if (corpusdir.exists()) {
-					return null;
-				}
-			} else {
-				return null; // abandon
 			}
 		}
 
