diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 95c2d18072dfb41314233b9503961eee16bbb6a3..73385666c3d8ff7a4f0826cf09df61e0853b539e 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -1031,9 +1031,9 @@ class LDAP
         $line .= substr($fileLine, 1);
       } else {
         if ($line !== NULL) {
-          if (preg_match('/^#/', $line)) {
+          if (preg_match('/^#/', $line)
+            || (preg_match('/^version:/', $line) && empty($entry))) {
             /* Ignore comment */
-          } elseif (preg_match('/^version:/', $line) && empty($entry)) {
             /* Ignore version number */
           } else {
             /* Line has ended */
diff --git a/include/functions.inc b/include/functions.inc
index dd1f5e7fd43b870c3eb81aadc58651f50100ef3d..85086dda6e440b357d6704d51a90c1186ba77fc2 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -1574,6 +1574,8 @@ function to_byte($value)
       case 'k':
         $mult = 1024;
         break;
+      default:
+        return $value;
     }
 
     return $mult * (int)substr($value, 0, -1);
diff --git a/include/php_setup.inc b/include/php_setup.inc
index 3bb7ba0b907ea1ed9f7823b29f8cf4abc9856b74..b183e324fca0fb3c16d2f956e575954014cb2de8 100644
--- a/include/php_setup.inc
+++ b/include/php_setup.inc
@@ -79,6 +79,10 @@ function html_trace($errstr = "")
         case "->":
           $type = _("method");
           break;
+
+        default:
+          $type = 'unknown';
+          break;
       }
     } else {
       $type = "-";
diff --git a/include/simpleplugin/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc
index 59d1587d6a2f6627a354acfe058273d590d94df2..7b0f66de0b977328233b5948157e5c8c21ae7cc7 100644
--- a/include/simpleplugin/attributes/class_DateAttribute.inc
+++ b/include/simpleplugin/attributes/class_DateAttribute.inc
@@ -44,9 +44,10 @@ class DateAttribute extends Attribute
 
   function inputValue ($value)
   {
-    if ($value === "" && !$this->isRequired()) {
-      return $value;
-    } elseif ($this->isTemplate() && preg_match('/%/', $value)) {
+    if (
+        (($value === '') && !$this->isRequired()) ||
+        ($this->isTemplate() && preg_match('/%/', $value))
+      ) {
       return $value;
     } else {
       return $this->ldapToDate($value);
diff --git a/include/simpleplugin/class_dialogAttributes.inc b/include/simpleplugin/class_dialogAttributes.inc
index 06c845741c42b71350faae01349f85940e90cff3..d0f35ec3d59df23a60e43acbd881345993dbe523 100644
--- a/include/simpleplugin/class_dialogAttributes.inc
+++ b/include/simpleplugin/class_dialogAttributes.inc
@@ -374,9 +374,10 @@ class GenericDialogAttribute extends DialogAttribute
 
   function addValue ($dn, $attrs)
   {
-    if ($this->isTemplate() && ($attrs === NULL)) {
-      $value = $dn;
-    } elseif ($this->store_attr == 'dn') {
+    if (
+        ($this->isTemplate() && ($attrs === NULL)) ||
+        ($this->store_attr == 'dn')
+      ) {
       $value = $dn;
     } else {
       $value = $attrs[$this->store_attr][0];
diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index 40c4d1346073e4de7a46f92bf2c5b089ce89a015..f6b31f7bb2ff771cd9cda574f7bdc59bc9ca9856 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -533,9 +533,10 @@ class simplePlugin
 
     /* Is this a new object ? Or just an edited existing object */
     foreach ($config->idepartments as $dn => $name) {
-      if (!$this->initially_was_account && $this->acl_is_createable($dn)) {
-        $deps[$dn] = $name;
-      } elseif ($this->initially_was_account && $this->acl_is_moveable($dn)) {
+      if (
+          (!$this->initially_was_account && $this->acl_is_createable($dn)) ||
+          ($this->initially_was_account && $this->acl_is_moveable($dn))
+        ) {
         $deps[$dn] = $name;
       }
     }
@@ -796,11 +797,10 @@ class simplePlugin
       $attr = $this->attributesAccess[$attr];
     }
     if ($attr->getLdapName() == 'base') {
-      if (!$this->acl_skip_write() && (!$this->initially_was_account || $this->acl_is_moveable() || $this->acl_is_removeable())) {
-        return TRUE;
-      } else {
-        return FALSE;
-      }
+      return (
+        !$this->acl_skip_write() &&
+        (!$this->initially_was_account || $this->acl_is_moveable() || $this->acl_is_removeable())
+      );
     }
     return $this->acl_is_writeable($attr->getAcl(), $this->acl_skip_write());
   }
@@ -1086,27 +1086,23 @@ class simplePlugin
     if (isset($_POST[get_class($this).'_posted'])) {
       // If our form has been posted
       // A first pass that loads the post values
-      foreach ($this->attributesInfo as $section => &$sectionInfo) {
-        foreach ($sectionInfo['attrs'] as &$attr) {
+      foreach ($this->attributesInfo as $sectionInfo) {
+        foreach ($sectionInfo['attrs'] as $attr) {
           if ($this->attrIsWriteable($attr)) {
             // Each attribute know how to read its value from POST
             $attr->loadPostValue();
           }
         }
-        unset ($attrs);
       }
-      unset($sectionInfo);
       // A second one that applies them. That allow complex stuff such as attribute disabling
-      foreach ($this->attributesInfo as $section => &$sectionInfo) {
-        foreach ($sectionInfo['attrs'] as &$attr) {
+      foreach ($this->attributesInfo as $sectionInfo) {
+        foreach ($sectionInfo['attrs'] as $attr) {
           if ($this->attrIsWriteable($attr)) {
             // Each attribute know how to read its value from POST
             $attr->applyPostValue();
           }
         }
-        unset ($attrs);
       }
-      unset($sectionInfo);
     }
   }
 
@@ -1279,7 +1275,7 @@ class simplePlugin
     $this->attrs['objectClass'] = $this->mergeObjectClasses($oc);
 
     /* Fill attributes LDAP values into the attrs array */
-    foreach ($this->attributesInfo as $section => $sectionInfo) {
+    foreach ($this->attributesInfo as $sectionInfo) {
       foreach ($sectionInfo['attrs'] as $attr) {
         $attr->fillLdapValue($this->attrs);
       }
@@ -1610,10 +1606,11 @@ class simplePlugin
       $infos = pluglist::pluginInfos($tabclass);
       foreach ($infos['plForeignRefs'] as $field => $refs) {
         if (preg_match('/^handle_/', $mode)) {
-          if (($newdn !== NULL) && ($field != 'dn') && ($mode == 'handle_move')) {
+          if (
+              (($newdn !== NULL) && ($field != 'dn') && ($mode == 'handle_move')) ||
+              (($newdn === NULL) && ($olddn === NULL) && (($field == 'dn') || (!$this->attributeHaveChanged($field))))
+            ) {
             // Move action, ignore other fields than dn
-            continue;
-          } elseif (($newdn === NULL) && ($olddn === NULL) && (($field == 'dn') || (!$this->attributeHaveChanged($field)))) {
             // Edit action, ignore dn changes or attributes which did not change
             continue;
           }
diff --git a/plugins/admin/acl/class_aclAssignment.inc b/plugins/admin/acl/class_aclAssignment.inc
index 429871c6f93f820bc3500e834a5fe28e33f60fbf..d4284f2542e04dfcdae2c4e0bce17103b8d59203 100644
--- a/plugins/admin/acl/class_aclAssignment.inc
+++ b/plugins/admin/acl/class_aclAssignment.inc
@@ -246,9 +246,10 @@ class ACLsAssignmentAttribute extends DialogOrderedArrayAttribute
   function foreignKeyCheck($oldvalue, $source)
   {
     foreach ($this->value as $value) {
-      if (($source['CLASS'] == 'aclRole') && ($value['role'] == $oldvalue)) {
-        return TRUE;
-      } elseif (in_array($source['CLASS'], array('user','posixGroup','roleGeneric')) && in_array($oldvalue, $value['members'])) {
+      if (
+          (($source['CLASS'] == 'aclRole') && ($value['role'] == $oldvalue)) ||
+          (in_array($source['CLASS'], array('user','posixGroup','roleGeneric')) && in_array($oldvalue, $value['members']))
+        ) {
         return TRUE;
       } elseif (!in_array($source['CLASS'], array('aclRole','user','posixGroup','roleGeneric'))) {
         trigger_error('unknown source '.$source['CLASS']);