diff --git a/include/class_template.inc b/include/class_template.inc
index 17e9616e2e2b979a4d9e5f088b2e852900b73fbf..7e82bbce5d75a6cf07d3b6c763b585960b2867af 100644
--- a/include/class_template.inc
+++ b/include/class_template.inc
@@ -68,22 +68,18 @@ class template
     return $result;
   }
 
-  function __construct ($type, $dn, $targetdn = NULL)
+  function __construct ($type, $dn)
   {
     $this->type = $type;
     $this->dn   = $dn;
     list($this->attrs, $depends) = templateHandling::fetch($this->dn);
     $this->needed     = templateHandling::neededAttrs($this->attrs, $depends);
     $this->needed[]   = 'base';
-    if ($targetdn === NULL) {
-      $this->tabObject  = objects::create($this->type);
-    } else {
-      trigger_error("This should not be used for now");
-      $this->tabObject  = objects::open($this->dn, $this->type);
-    }
-    $tempTabObject    = objects::open($this->dn, $this->type); /* Used to know which tab is activated */
-    $this->attributes = [];
+    $this->tabObject  = objects::create($this->type);
+    /* Used to know which tab is activated */
+    $tempTabObject    = objects::open($this->dn, $this->type);
     $tempTabObject->setActiveTabs($this->tabObject);
+    $this->attributes = [];
     foreach ($this->tabObject->by_object as $class => $tab) {
       if ($tab->is_account || $tab->ignore_account) {
         $this->attributes[$class] = [];
@@ -114,11 +110,7 @@ class template
     $this->tabObject  = objects::create($this->type);
     /* Used to know which tab is activated */
     $tempTabObject    = objects::open($this->dn, $this->type);
-    foreach ($tempTabObject->by_object as $class => $plugin) {
-      if ($plugin->is_account || $plugin->ignore_account) {
-        $this->tabObject->by_object[$class]->is_account = $plugin->is_account;
-      }
-    }
+    $tempTabObject->setActiveTabs($this->tabObject);
     $this->applied = FALSE;
   }
 
diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index 85f35b0a7d6bac146dd225d55963da724c283950..3adb17807a221447e2d24a2a4eabfa0a62ff9cd7 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -1913,7 +1913,7 @@ class simplePlugin implements SimpleTab
     throw new FusionDirectoryException(_('Failed to create a unique DN'));
   }
 
-  /*
+  /*!
    * \brief Adapt from template
    *
    * Adapts fields to the values from a template.
@@ -2010,7 +2010,10 @@ class simplePlugin implements SimpleTab
     return TRUE;
   }
 
-  /* Returns TRUE if this attribute should be asked in the creation by template dialog */
+  /*! \brief Returns TRUE if this attribute should be asked in the creation by template dialog
+   *
+   * \return bool whether this attribute should be asked
+   */
   function showInTemplate (string $attr, array $templateAttrs): bool
   {
     if (isset($templateAttrs[$attr])) {
diff --git a/plugins/personal/generic/class_UserPasswordAttribute.inc b/plugins/personal/generic/class_UserPasswordAttribute.inc
index 7b73efaa96a729f415b5c87f35ca1c67c9271aef..6a8cdf87f4cddc625f4936b7d8a801b805fd056e 100644
--- a/plugins/personal/generic/class_UserPasswordAttribute.inc
+++ b/plugins/personal/generic/class_UserPasswordAttribute.inc
@@ -199,6 +199,11 @@ class UserPasswordAttribute extends CompositeAttribute
         $pw_storage = $tmp->get_hash();
         $locked     = $tmp->is_locked('', $value);
       }
+      if ($istemplate && empty($password)) {
+        /* Do not store hash for templates,
+         * we have the password anyway, and this avoids problems with empty passwords */
+        $value = $this->attributes[3]->getValue();
+      }
     }
     return [$pw_storage, $password, $password, $value, ($locked ? 'TRUE' : 'FALSE')];
   }