diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index f04d4f0836f6ca155dfe0b6c695d5e9f6b350664..ee3deec13dcf70f3b035ce755af5af215485c561 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -1,9 +1,8 @@
 <?php
-
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003-2010  Cajus Pollmeier
-  Copyright (C) 2011-2016  FusionDirectory
+  Copyright (C) 2011-2017  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -216,11 +215,10 @@ class CopyPasteHandler
       $this->save_object();
       foreach ($this->clean_objects as $key => $entry) {
         $this->current = $entry;
-        $dn     = $this->current['object']->dn;
         $errors = $this->current['object']->save();
 
         if (empty($errors)) {
-          $this->current_saved($dn);
+          $this->current_saved();
           /* Remove from queue -> avoid saving twice */
           unset($this->queue[$key]);
         } else {
@@ -234,17 +232,15 @@ class CopyPasteHandler
     /* Save edited entry and force loading new one */
     if (isset($this->current['object'])) {
       $this->current['object']->save_object();
-    }
-
-    /* Save current object if edition is finished */
-    if (isset($_POST['edit_finish']) && $this->current) {
-      $dn     = $this->current['object']->dn;
-      $errors = $this->current['object']->save();
+      /* Save current object if edition is finished */
+      if (isset($_POST['edit_finish'])) {
+        $errors = $this->current['object']->save();
 
-      if (empty($errors)) {
-        $this->current_saved($dn);
-      } else {
-        msg_dialog::displayChecks($errors);
+        if (empty($errors)) {
+          $this->current_saved();
+        } else {
+          msg_dialog::displayChecks($errors);
+        }
       }
     }
 
@@ -275,12 +271,12 @@ class CopyPasteHandler
         }
       }
     }
-    return "";
+    return '';
   }
 
-  private function current_saved($dn)
+  private function current_saved()
   {
-    $this->lastdn   = $dn;
+    $this->lastdn   = $this->current['object']->dn;
     $this->handleReferences();
     $this->current  = FALSE;
   }
diff --git a/include/class_baseSelector.inc b/include/class_baseSelector.inc
index c88485e6c05ec96496275dc16ea9a6a4644dd383..1d85e196f8ac886b0feb6a9f2c75ba58d48be5fa 100644
--- a/include/class_baseSelector.inc
+++ b/include/class_baseSelector.inc
@@ -2,7 +2,7 @@
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003-2010  Cajus Pollmeier
-  Copyright (C) 2011-2016  FusionDirectory
+  Copyright (C) 2011-2017  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -151,7 +151,7 @@ class baseSelector {
     $this->action = NULL;
     $last_base    = $this->base;
     if (isset($_REQUEST['BPID']) && $_REQUEST['BPID'] == $this->pid) {
-      if (isset($_POST['bs_rebase_'.$this->pid]) && !empty($_POST['bs_rebase_'.$this->pid])) {
+      if (!empty($_POST['bs_rebase_'.$this->pid])) {
         $new_base = base64_decode($_POST['bs_rebase_'.$this->pid]);
         if (isset($this->pathMapping[$new_base])) {
           $this->base   = $new_base;
@@ -160,21 +160,17 @@ class baseSelector {
           $this->lastState = FALSE;
           return FALSE;
         }
-      } else {
-        // Input field set?
-        if (isset($_POST[$this->getInputHtmlId()])) {
-
-          // Take over input field base
-          if ($this->submitButton && isset($_POST['submit_base_'.$this->pid.'_x']) || !$this->submitButton) {
-
-            // Check if base is available
-            $this->lastState = FALSE;
-            foreach ($this->pathMapping as $key => $path) {
-              if (mb_strtolower($path) == mb_strtolower($_POST[$this->getInputHtmlId()])) {
-                $this->base       = $key;
-                $this->lastState  = TRUE;
-                break;
-              }
+      } elseif (isset($_POST[$this->getInputHtmlId()])) {
+        // Take over input field base
+        if (($this->submitButton && isset($_POST['submit_base_'.$this->pid.'_x'])) || !$this->submitButton) {
+
+          // Check if base is available
+          $this->lastState = FALSE;
+          foreach ($this->pathMapping as $key => $path) {
+            if (mb_strtolower($path) == mb_strtolower($_POST[$this->getInputHtmlId()])) {
+              $this->base       = $key;
+              $this->lastState  = TRUE;
+              break;
             }
           }
         }
@@ -205,13 +201,12 @@ class baseSelector {
     }
     $this->tree .= "</script>";
 
-    $selected     = $this->base == $config->current['BASE']?"Selected":"";
+    $selected     = ($this->base == $config->current['BASE'] ? 'Selected' : '');
     $this->tree   .= "<div class='treeList' style='display:none;max-height:".$this->height."px' id='bs_".$this->pid."' onmouseover=\"window.clearTimeout(rtimer);\" onmouseout=\"rtimer= Element.hide.delay(0.25, 'bs_".$this->pid."')\"><a class='treeList$selected' $link>/&nbsp;["._("Root")."]</a><ul class='treeList'>\n";
     $first        = TRUE;
     $last_indent  = 2;
 
     foreach ($this->pathMapping as $base => $dummy) {
-
       // Skip root for tree
       if ($base == $config->current['BASE']) {
         continue;
@@ -223,25 +218,23 @@ class baseSelector {
       $indent = count($elements);
       if (!$first && ($indent == $last_indent)) {
         $this->tree .= "</li>\n";
-      }
-      if ($indent > $last_indent) {
+      } elseif ($indent > $last_indent) {
         $this->tree .= "<ul>\n";
-      }
-      if ($indent < $last_indent) {
+      } elseif ($indent < $last_indent) {
         for ($i = 0; $i < ($last_indent - $indent); $i++) {
           $this->tree .= "</li></ul>\n";
         }
         $this->tree .= "</li>\n";
       }
-      $selected   = ($this->base == $base?" class='treeListSelected'":"");
+      $selected   = ($this->base == $base ? ' class="treeListSelected"' : '');
       $link       = "onclick=\"\$('bs_rebase_".$this->pid."').value='".base64_encode($base)."';$('submit_tree_base_".$this->pid."').click();\"";
       $this->tree .= "<li><a$selected $link>".
                     '<img class="center" '.
                     'src="'.htmlentities($config->department_info[$base]['img'], ENT_COMPAT, 'UTF-8').'" '.
                     'alt="'.$config->department_info[$base]['name'].'"/>&nbsp;'.
                     $this->gennonbreaks($config->department_info[$base]['name']).
-                    ($config->department_info[$base]['description'] == ''?'':'&nbsp;<span class="informal">['.$this->gennonbreaks($config->department_info[$base]['description']).']</span>').
-                    "</a>";
+                    ($config->department_info[$base]['description'] == '' ? '' : '&nbsp;<span class="informal">['.$this->gennonbreaks($config->department_info[$base]['description']).']</span>').
+                    '</a>';
 
       $last_indent  = $indent;
       $first        = FALSE;
@@ -260,9 +253,9 @@ class baseSelector {
     if ($this->submitButton) {
       $this->tree .= "&nbsp;<input class='center' type='image' src='geticon.php?context=actions&amp;icon=submit&amp;size=16' title='"._("Submit")."' name='submit_base_".$this->pid."' id='submit_base_".$this->pid."' alt='"._("Submit")."'>";
     }
-    $this->tree .= "<input type='submit' style='display:none' name='submit_tree_base_".$this->pid."' id='submit_tree_base_".$this->pid."'>";
-    $this->tree .= "<input type='hidden' name='bs_rebase_".$this->pid."' id='bs_rebase_".$this->pid."'>";
-    $this->tree .= "<input type='hidden' name='BPID' id='BPID' value='".$this->pid."'>";
+    $this->tree .= '<input type="submit" style="display:none" name="submit_tree_base_'.$this->pid.'" id="submit_tree_base_'.$this->pid.'"/>';
+    $this->tree .= '<input type="hidden" name="bs_rebase_'.$this->pid.'" id="bs_rebase_'.$this->pid.'"/>';
+    $this->tree .= '<input type="hidden" name="BPID" id="BPID" value="'.$this->pid.'"/>';
 
     $this->lastState = TRUE;
     return TRUE;
diff --git a/include/class_config.inc b/include/class_config.inc
index 90a68a9d148728f9dd09aa87274194e405321047..5d749784b03054cf26567bfcd575c0c020786ab4 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -1,9 +1,8 @@
 <?php
-
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
   Copyright (C) 2003-2010  Cajus Pollmeier
-  Copyright (C) 2011-2016  FusionDirectory
+  Copyright (C) 2011-2017  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -29,17 +28,16 @@
  * \brief This class is responsible for parsing and querying the
  * fusiondirectory configuration file.
  */
-
-class config  {
-
+class config
+{
   /* XML parser */
   var $parser;
   var $config_found     = FALSE;
   var $tags             = array();
   var $level            = 0;
   var $gpc              = 0;
-  var $section          = "";
-  var $currentLocation  = "";
+  var $section          = '';
+  var $currentLocation  = '';
 
   /*!
    * \brief Store configuration for current location
@@ -60,16 +58,15 @@ class config  {
     'SERVERS'   => array(),
     'MAIN'      => array(),
   );
-  var $basedir        = "";
+  var $basedir        = '';
 
   /* Keep a copy of the current department list */
   var $departments      = array();
   var $idepartments     = array();
   var $department_info  = array();
-  var $filename         = "";
+  var $filename         = '';
   var $last_modified    = 0;
 
-
   /*!
    * \brief Class constructor of the config class
    *
@@ -77,17 +74,16 @@ class config  {
    *
    * \param string $basedir base directory
    */
-  function __construct($filename, $basedir = "")
+  function __construct($filename, $basedir = '')
   {
     $this->basedir  = $basedir;
 
     /* Parse config file directly? */
-    if ($filename != "") {
+    if ($filename != '') {
       $this->parse($filename);
     }
   }
 
-
   /*!
    * \brief Check and reload the configuration
    *
@@ -99,29 +95,28 @@ class config  {
   {
     /* Check if class_location.inc has changed, this is the case
         if we have installed or removed plugins. */
-    $tmp = stat(CACHE_DIR."/".CLASS_CACHE);
-    if (session::global_is_set("class_location.inc:timestamp")) {
-      if ($tmp['mtime'] != session::global_get("class_location.inc:timestamp")) {
-        session::global_un_set("plist");
+    $tmp = stat(CACHE_DIR.'/'.CLASS_CACHE);
+    if (session::global_is_set('class_location.inc:timestamp')) {
+      if ($tmp['mtime'] != session::global_get('class_location.inc:timestamp')) {
+        session::global_un_set('plist');
       }
     }
-    session::global_set("class_location.inc:timestamp", $tmp['mtime']);
+    session::global_set('class_location.inc:timestamp', $tmp['mtime']);
 
-    if (($this->filename != "") && ((filemtime($this->filename) != $this->last_modified) || $force)) {
+    if (($this->filename != '') && ((filemtime($this->filename) != $this->last_modified) || $force)) {
 
       $this->config_found     = FALSE;
       $this->tags             = array();
       $this->level            = 0;
       $this->gpc              = 0;
-      $this->section          = "";
-      $this->currentLocation  = "";
+      $this->section          = '';
+      $this->currentLocation  = '';
 
       $this->parse($this->filename);
       $this->set_current($this->current['NAME']);
     }
   }
 
-
   /*!
    * \brief Parse the given configuration file
    *
@@ -134,7 +129,7 @@ class config  {
   {
     $this->last_modified  = filemtime($filename);
     $this->filename       = $filename;
-    $fh       = fopen($filename, "r");
+    $fh       = fopen($filename, 'r');
     $xmldata  = fread($fh, 100000);
     fclose($fh);
     $this->parse_data($xmldata);
@@ -162,7 +157,6 @@ class config  {
     xml_parser_free($this->parser);
   }
 
-
   /*!
    * \brief Open xml tag when parsing the xml config
    *
@@ -236,7 +230,6 @@ class config  {
     }
   }
 
-
   /*!
    * \brief Close xml tag when parsing the xml config
    *
@@ -253,7 +246,6 @@ class config  {
     $this->level--;
   }
 
-
   /*!
    * \brief Get the password when needed from the config file
    *
@@ -290,7 +282,6 @@ class config  {
     return $creds;
   }
 
-
   /*!
    * \brief Get a LDAP link object
    *
@@ -345,7 +336,6 @@ class config  {
     return $obj;
   }
 
-
   /*!
    * \brief Set the current location
    *
@@ -437,7 +427,6 @@ class config  {
     initLanguage();
   }
 
-
   /*!
    * \brief Load server information from config/LDAP
    *
@@ -624,7 +613,6 @@ class config  {
       /* Add last ou element of current dn to our array */
       $last = &$arr;
       foreach ($elements as $key => $ele) {
-
         /* skip empty */
         if (empty($ele)) {
           continue;
@@ -655,7 +643,6 @@ class config  {
     $this->idepartments = $this->generateDepartmentArray($ret, -1, $max_size);
   }
 
-
   /*
    * \brief Creates display friendly output from make_idepartments
    *
@@ -744,7 +731,7 @@ class config  {
    *
    * \return string the configuration value if found or the default value
    */
-  function get_cfg_value($name, $default = "")
+  function get_cfg_value($name, $default = '')
   {
     $name = strtoupper($name);
     $res  = $default;
@@ -752,9 +739,9 @@ class config  {
     /* Check if we have a current value for $name */
     if (isset($this->current[$name])) {
       $res = $this->current[$name];
-    } elseif (isset($this->data["MAIN"][$name])) {
+    } elseif (isset($this->data['MAIN'][$name])) {
       /* Check if we have a global value for $name */
-      $res = $this->data["MAIN"][$name];
+      $res = $this->data['MAIN'][$name];
     }
 
     if (is_array($default) && !is_array($res)) {
@@ -764,7 +751,6 @@ class config  {
     return $res;
   }
 
-
   /*!
    * \brief Check if session lifetime matches session.gc_maxlifetime
    *
@@ -790,7 +776,6 @@ class config  {
     }
   }
 
-
   /*!
    * \brief Check if snapshot are enabled
    *
@@ -798,35 +783,33 @@ class config  {
    */
   function snapshotEnabled()
   {
-    if ($this->get_cfg_value("enableSnapshots") == "TRUE") {
-
-      /* Check if the snapshot_base is defined */
-      if ($this->get_cfg_value("snapshotBase") == "") {
+    if ($this->get_cfg_value('enableSnapshots') != 'TRUE') {
+      return FALSE;
+    }
 
-        /* Send message if not done already */
-        if (!session::is_set("snapshotFailMessageSend")) {
-          session::set("snapshotFailMessageSend", TRUE);
-          msg_dialog::display(_("Configuration error"),
-              sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."),
-                      "snapshotBase"), ERROR_DIALOG);
-        }
-        return FALSE;
+    /* Check if the snapshot_base is defined */
+    if ($this->get_cfg_value('snapshotBase') == '') {
+      /* Send message if not done already */
+      if (!session::is_set('snapshotFailMessageSend')) {
+        session::set('snapshotFailMessageSend', TRUE);
+        msg_dialog::display(_('Configuration error'),
+            sprintf(_('The snapshot functionality is enabled, but the required variable "%s" is not set.'),
+                    'snapshotBase'), ERROR_DIALOG);
       }
+      return FALSE;
+    }
 
-      /* Check if gzcompress is available */
-      if (!is_callable("gzcompress")) {
-
-        /* Send message if not done already */
-        if (!session::is_set("snapshotFailMessageSend")) {
-          session::set("snapshotFailMessageSend", TRUE);
-          msg_dialog::display(_("Configuration error"),
-              sprintf(_("The snapshot functionality is enabled, but the required compression module is missing. Please install '%s'."), "php5-zip / php5-gzip"), ERROR_DIALOG);
-        }
-        return FALSE;
+    /* Check if gzcompress is available */
+    if (!is_callable('gzcompress')) {
+      /* Send message if not done already */
+      if (!session::is_set('snapshotFailMessageSend')) {
+        session::set('snapshotFailMessageSend', TRUE);
+        msg_dialog::display(_('Configuration error'),
+            sprintf(_('The snapshot functionality is enabled, but the required compression module is missing. Please install "%s".'), 'php5-zip / php5-gzip'), ERROR_DIALOG);
       }
-      return TRUE;
+      return FALSE;
     }
-    return FALSE;
+    return TRUE;
   }
 
   function loadPlist (pluglist $plist)
@@ -906,7 +889,7 @@ class config  {
         /* Walk through supplied list and feed only translated categories */
         $cats = array();
         foreach ($plInfo['plCategory'] as $idx => $data) {
-          $cat    = (is_numeric($idx)?$data:$idx);
+          $cat    = (is_numeric($idx) ? $data : $idx);
           $cats[] = $cat;
           if (!isset($this->data['CATEGORIES'][$cat])) {
             $this->data['CATEGORIES'][$cat] = array( 'classes' => array('0') );
@@ -1081,5 +1064,4 @@ class config  {
     );
   }
 }
-
 ?>
diff --git a/include/class_filter.inc b/include/class_filter.inc
index c06b289978bd678d012328ddbbb929fb43e79232..4133687a9f9a700a7e162928c62e0808e113aa20 100644
--- a/include/class_filter.inc
+++ b/include/class_filter.inc
@@ -34,13 +34,13 @@ class filter
   var $elementValues    = array();
   var $alphabetElements = array();
   var $autocompleter    = array();
-  var $category         = "";
+  var $category         = '';
   var $objectStorage    = array();
-  var $base             = "";
-  var $scope            = "";
+  var $base             = '';
+  var $scope            = '';
   var $query;
   var $initial          = FALSE;
-  var $scopeMode        = "auto";
+  var $scopeMode        = 'auto';
   var $alphabet         = NULL;
   var $converter        = array();
   var $pid;
@@ -71,33 +71,25 @@ class filter
     $contents       = file_get_contents($filename);
     $this->xmlData  = xml::xml2array($contents, 1);
 
-    if (!isset($this->xmlData['filterdef'])) {
+    if (!isset($this->xmlData['filterdef']['search'])) {
       return FALSE;
     }
 
-    $this->xmlData = $this->xmlData["filterdef"];
+    $this->xmlData = $this->xmlData['filterdef'];
 
     // Load filter
-    if (isset($this->xmlData['search'])) {
-      if (!isset($this->xmlData['search']['query'][0])) {
-        $this->xmlData['search']['query'] = array($this->xmlData['search']['query']);
-      }
-
-      // Move information
-      $entry            = $this->xmlData['search'];
-      $this->scopeMode  = $entry['scope'];
-      if ($entry['scope'] == "auto") {
-        $this->scope = "one";
-      } else {
-        $this->scope = $entry['scope'];
-      }
-      $this->query = $entry['query'];
-    } else {
-      return FALSE;
+    if (!isset($this->xmlData['search']['query'][0])) {
+      $this->xmlData['search']['query'] = array($this->xmlData['search']['query']);
     }
 
+    // Move information
+    $entry            = $this->xmlData['search'];
+    $this->scopeMode  = $entry['scope'];
+    $this->scope      = ($entry['scope'] == 'auto' ? 'one' : $entry['scope']);
+    $this->query      = $entry['query'];
+
     // Transfer initial value
-    if (isset($this->xmlData['definition']['initial']) && ($this->xmlData['definition']['initial'] == "true")) {
+    if (isset($this->xmlData['definition']['initial']) && ($this->xmlData['definition']['initial'] == 'true')) {
       $this->initial = TRUE;
     }
 
@@ -112,7 +104,6 @@ class filter
         $this->xmlData['element'] = array($this->xmlData['element']);
       }
       foreach ($this->xmlData['element'] as $element) {
-
         // Ignore elements without type
         if (!isset($element['type']) || !isset($element['tag'])) {
           continue;
@@ -132,18 +123,17 @@ class filter
         if (isset($element['default']) && !is_array($element['default'])) {
           $this->elementValues[$tag] = $element['default'];
         } else {
-          $this->elementValues[$tag] = "";
+          $this->elementValues[$tag] = '';
         }
 
         // Does this element react on alphabet links?
-        if (isset($element['alphabet']) && $element['alphabet'] == "true") {
+        if (isset($element['alphabet']) && ($element['alphabet'] == 'true')) {
           $this->alphabetElements[] = $tag;
         }
       }
 
       uasort($this->elements, 'strlenSort');
       $this->elements = array_reverse($this->elements);
-
     }
 
     return TRUE;
@@ -360,7 +350,7 @@ class filter
    */
   function renderScope()
   {
-    $checked = ($this->scope == "sub"?" checked":"");
+    $checked = ($this->scope == 'sub' ? ' checked' : '');
     return "<input type='checkbox' id='SCOPE' name='SCOPE' value='1' onClick='document.mainform.submit();'$checked>&nbsp;<LABEL for='SCOPE'>"._("Search in subtrees")."</LABEL>";
   }
 
@@ -430,13 +420,13 @@ class filter
     // Go thru all queries and merge results
     foreach ($this->query as $query) {
       if (!isset($query['backend']) || !isset($query['filter']) || !isset($query['attribute'])) {
-        die("No backend specified in search config.");
+        die('No backend specified in search config.');
       }
 
       // Is backend available?
-      $backend = "filter".$query['backend'];
+      $backend = 'filter'.$query['backend'];
       if (!isset($class_mapping["$backend"])) {
-        die("Invalid backend specified in search config.");
+        die('Invalid backend specified in search config.');
       }
 
       // Load filter and attributes
@@ -464,15 +454,15 @@ class filter
         // Handle converters if present
         if (isset($this->converter[$tag])) {
           preg_match('/([^:]+)::(.*)$/', $this->converter[$tag], $m);
-          $e_set    = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['set'])?"":$element['set']));
-          $e_unset  = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['unset'])?"":$element['unset']));
+          $e_set    = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['set']) ? '' : $element['set']));
+          $e_unset  = call_user_func(array($m[1], $m[2]), preg_replace('/\$/', $this->elementValues[$tag], is_array($element['unset']) ? '' : $element['unset']));
         } else {
-          $e_set    = is_array($element['set'])?"":$element['set'];
-          $e_unset  = is_array($element['unset'])?"":$element['unset'];
+          $e_set    = (is_array($element['set']) ? '' : $element['set']);
+          $e_unset  = (is_array($element['unset']) ? '' : $element['unset']);
         }
 
         // Do not replace escaped \$ - This is required to be able to search for e.g. windows machines.
-        if ($this->elementValues[$tag] == "") {
+        if ($this->elementValues[$tag] == '') {
           $e_unset  = preg_replace('/([^\\\\])\$/', '${1}'.ldap_escape_f($this->elementValues[$tag]), $e_unset);
           $e_unset  = preg_replace('/\\\\\$/', '$', $e_unset);
           $filter   = preg_replace("/\\$$tag/", $e_unset, $filter);
@@ -539,8 +529,8 @@ class filter
       }
 
       // Save scope if needed
-      if ($this->scopeMode == "auto") {
-        $this->scope = (isset($_POST['SCOPE'])?"sub":"one");
+      if ($this->scopeMode == 'auto') {
+        $this->scope = (isset($_POST['SCOPE']) ? 'sub' : 'one');
       }
     }