diff --git a/Fltk/onelabGroup.cpp b/Fltk/onelabGroup.cpp
index 65c571f7bfeb5518718f73e528cad2a7c81b8c5b..5c9c2aa7cfec7bd8abbc9bef428e54ab846f2547 100644
--- a/Fltk/onelabGroup.cpp
+++ b/Fltk/onelabGroup.cpp
@@ -656,8 +656,8 @@ static void archiveOutputFiles(const std::string &fileName)
   std::string stamp;
   std::vector<onelab::string> ps;
   onelab::server::instance()->get(ps,"0Metamodel/9Tag");
-  if(ps.size())
-    stamp.assign(timeStamp() + ps[0].getValue());
+  if(ps.size() && ps[0].getValue().size())
+    stamp.assign(timeStamp() + "_" + ps[0].getValue());
   else
     stamp.assign(timeStamp());
 
@@ -700,9 +700,12 @@ static void archiveOutputFiles(const std::string &fileName)
 
 static void archiveSolutionFiles(const std::string &fileName)
 {
-  // extract tag from dbName
+  // extract tag from db fileName, use fileName as tag otherwise
   std::vector<std::string> split = SplitFileName(fileName);
-  std::string tag = split[1].substr(6); // cut off 'onelab'
+  std::string dir = split[0] + "archive/";
+  std::string tag = split[1];
+  if (!tag.compare(0,6,"onelab"))
+    tag.assign(tag.substr(6)); // cut off 'onelab' if present
 
   // add tag to all solution files in the db, and rename them on disk
   std::vector<onelab::string> strings;
@@ -713,8 +716,8 @@ static void archiveSolutionFiles(const std::string &fileName)
       for(unsigned int j = 0; j < names.size(); j++){
 	std::vector<std::string> split = SplitFileName(names[j]);
 	std::string old = names[j];
-	CreateSingleDir(split[0] + "archive/");
-	names[j] = split[0] + "archive/" + split[1] + tag + split[2];
+	CreateSingleDir(dir);
+	names[j] = dir + split[1] + tag + split[2];
 	Msg::Info("Renaming '%s' into '%s'", old.c_str(), names[j].c_str());
 	rename(old.c_str(), names[j].c_str());
       }
@@ -839,17 +842,15 @@ void onelab_cb(Fl_Widget *w, void *data)
     // add user defined tag, if any
     std::vector<onelab::string> ps;
     onelab::server::instance()->get(ps,"0Metamodel/9Tag");
-    if(ps.size()){
-      fileName.assign("onelab" + ps[0].getValue() + ".db");
-      //ps[0].setValue("");
-      //onelab::server::instance()->set(ps[0]);
+    if(ps.size() && ps[0].getValue().size()){
+	fileName.assign("onelab_" + ps[0].getValue() + ".db");
     }
 
-    // switch to "run" mode"
+    // save db in "restore" mode"
     std::vector<onelab::number> pn;
     onelab::server::instance()->get(pn,"0Metamodel/9Use restored solution");
     if(pn.size()){
-      pn[0].setValue(0);
+      pn[0].setValue(1);
       pn[0].setVisible(1);
       onelab::server::instance()->set(pn[0]);
     }
@@ -861,7 +862,15 @@ void onelab_cb(Fl_Widget *w, void *data)
       saveDb(fileChooserGetName(1));
     }
 
-    return;
+    // switch back to normal "run" mode"
+    onelab::server::instance()->get(pn,"0Metamodel/9Use restored solution");
+    if(pn.size()){
+      pn[0].setValue(0);
+      pn[0].setVisible(0);
+      onelab::server::instance()->set(pn[0]);
+    }
+    action = "check";
+    //return;
   }
 
   if(FlGui::instance()->onelab->isBusy()){
@@ -873,16 +882,6 @@ void onelab_cb(Fl_Widget *w, void *data)
     std::string db = SplitFileName(GModel::current()->getFileName())[0] + "onelab.db";
     if(fileChooser(FILE_CHOOSER_SINGLE, "Load", "*.db", db.c_str()))
       loadDb(fileChooserGetName(1));
-
-    // switch to "restore" mode"
-    // (the metamodel will use archived solution files)
-    std::vector<onelab::number> pn;
-    onelab::server::instance()->get(pn,"0Metamodel/9Use restored solution");
-    if(pn.size()){
-      pn[0].setValue(1);
-      pn[0].setVisible(1);
-      onelab::server::instance()->set(pn[0]);
-    }
     action = "check";
   }
 
diff --git a/contrib/onelab/python/onelab.py b/contrib/onelab/python/onelab.py
index d07eec7e686484ac71e4f51fa5e3807ccd6b2676..d9908664812ab5a06efdda8901032178042b905b 100755
--- a/contrib/onelab/python/onelab.py
+++ b/contrib/onelab/python/onelab.py
@@ -36,42 +36,22 @@ def file_exist(filename):
       return True
   except IOError:
     return False
-  
-def path(ref, inp=''):
-  # ref is a reference file name (not a directory)
-  # inp is an optional file or subdirectory name
-  # return the path to 'inp' in the same directory as 'ref' 
-  dirname = os.path.dirname(ref)
+
+def path(dirname, inp):
+  # dirname is a directory, can be empty if model called in cmd line
+  # inp is an aptional file or subdirectory name
+  # returns the path to 'inp' in the same directory as 'ref' 
   if not inp: 
-    if dirname:
-      return dirname
-    else :
-      return '.'
+    return dirname
   if inp[0] == '/' or inp[0] == '\\' or (len(inp) > 2 and inp[1] == '\:'):
     return inp # do nothing, inp is an absolute path
+  if inp[0] == '.' :
+    inp = inp[2:] # cut off heading './' or '.\'
   if dirname: 
     return dirname + os.sep + inp # append inp to the path of the reference file
   else:
     return inp
 
-class pth:
-  def path(self, ref, inp=''):
-    p = path(ref,inp)
-    if not os.path.exists(p):
-      self.errors += 1
-      self.msg += p + ' '
-    return p
-
-  def status(self):
-    return '%d path errors: %s' %(self.errors, self.msg)
-
-  def copy(self, here, there):
-    os.system('cp '+ here + ' ' + there)
-    
-  def __init__(self) :
-    self.errors = 0
-    self.msg = ''
-
 class _parameter() :
   _membersbase = [
     ('name', 'string'), ('label', 'string', ''), ('help', 'string', ''),
@@ -364,7 +344,7 @@ class client :
       if msg == "true" :
           return True
     return False
-
+  
   def isChanged(self, name) :
     if not self.socket :
       return
@@ -410,10 +390,11 @@ class client :
   def run(self, name, command, arguments=''):
     self.runSubClient(name, command, arguments)
 
-  def __init__(self):
+  def __init__(self, ref=''):
     self.socket = None
     self.name = ""
     self.addr = ""
+    self.wdir = os.path.dirname(ref)
     self._numSubClients = 0
     for i, v in enumerate(sys.argv) :
       if v == '-onelab':
@@ -424,7 +405,6 @@ class client :
     self.action = "compute" # default (subclients have no client.Action defined)
     self.action = self.getString(self.name + '/Action', False)
     self.setNumber('IsPyMetamodel',value=1,visible=0)
-    #self.defineNumber('0Metamodel/Loop',value=0,visible=0)
     self.loop = self.getNumber('0Metamodel/Loop', warn_if_not_found=False)
     self.batch = self.getNumber('0Metamodel/Batch', warn_if_not_found=False)
     self.sendInfo("Performing OneLab '" + self.action + "'")
@@ -472,7 +452,24 @@ class client :
       for line in iter(call.stderr.readline, b''):
         self._send(self._GMSH_ERROR, line.rstrip().encode('utf-8'))
       sys.exit(1)
-      
+  
+  def path(self, inp='') :
+    return path(self.wdir,inp)
+
+  def exists(self, p) :
+    if not os.path.exists(p):
+      self.sendError('path error: %s' %(p))
+      exit(0) 
+    return True
+
+  def cpath(self, inp='') :
+    p = path(self.wdir,inp)
+    self.exists(p)
+    return p
+
+  def copy(self, here, there):
+    os.system('cp '+ here + ' ' + there)
+    
   def upload(self, here, there, remote='') :
     if not here or not there :
       return
@@ -510,8 +507,9 @@ class client :
       if self.getNumber('0Metamodel/9Use restored solution') :
         return self.getStringChoices('0Metamodel/9Solution files')  
       else :
+        self.setNumber('0Metamodel/9Use restored solution', visible=0)
         self.setString('0Metamodel/9Solution files', value=list[0],
-                       choices=list, readOnly=1)      
+                       choices=list, readOnly=1)    
     return list
 
   def restoreSolution(self) :
@@ -521,11 +519,9 @@ class client :
     if list :
       self.setString('0Metamodel/9Output files', value=list[0],
                      choices=list, visible=1)
-#      self.setString(self.name+'/9Output files', value=list[0],
-#                     choices=list, visible=1)
 
 # tool to extract the (i, j)th element in an array file
-from rlcompleter import readline
+#from rlcompleter import readline
 def extract(filename,i,j):
     input = open(filename,'r')
     all_lines = input.readlines()