diff --git a/include/class_CopyPasteHandler.inc b/include/class_CopyPasteHandler.inc
index a54d977ef8f3e695955501477336eeaedb624d66..f59d0e935e097b7bcedf7abc97df7e8a6fadfd77 100644
--- a/include/class_CopyPasteHandler.inc
+++ b/include/class_CopyPasteHandler.inc
@@ -174,8 +174,7 @@ class CopyPasteHandler
    */
   function execute($base)
   {
-    $ui   = get_userinfo();
-    $type = $this->current['method'];
+    $ui = get_userinfo();
 
     /* Check which entries can be pasted directly.
      * Create a list of all entries that can be pasted directly.
diff --git a/include/class_SnapshotHandler.inc b/include/class_SnapshotHandler.inc
index 0b29a9433ed4f84b9a7817bf0f897f94a1b3d611..9b0041d6dbca1048a816ca3b5ac01fb86dca48a9 100644
--- a/include/class_SnapshotHandler.inc
+++ b/include/class_SnapshotHandler.inc
@@ -130,9 +130,6 @@ class SnapshotHandler {
       return array();
     }
 
-    // Load user info
-    $ui = get_userinfo();
-
     list($ldap, $snapshotLdap) = $this->get_ldap_links();
 
     // Initialize base
@@ -144,7 +141,6 @@ class SnapshotHandler {
     $snapshotLdap->ls("(objectClass=gosaSnapshotObject)", $base,
                       array("gosaSnapshotType", "gosaSnapshotTimestamp", "gosaSnapshotDN", "description"));
     while ($entry = $snapshotLdap->fetch()) {
-
       $chk = str_replace($base, "", $entry['dn']);
       if (preg_match("/,ou=/", $chk)) {
         continue;
@@ -253,9 +249,6 @@ class SnapshotHandler {
       $dns = array($dn);
     }
 
-    /* Get configuration from fusiondirectory.conf */
-    $config = $this->config;
-
     list($ldap, $ldap_to) = $this->get_ldap_links();
 
     /* check if the dn exists */
@@ -309,7 +302,6 @@ class SnapshotHandler {
       if (!$ldap->success()) {
         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $new_base, "", get_class()));
       }
-
     }
   }
 
@@ -389,7 +381,6 @@ class SnapshotHandler {
     /* Prepare bases */
     $new_base       = $this->snapshot_dn($base_of_object);
     /* Fetch all objects and check if they do not exist anymore */
-    $ui   = get_userinfo();
     $tmp  = array();
     $ldap_to->cd($new_base);
     $ldap_to->ls("(objectClass=gosaSnapshotObject)", $new_base, array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description"));
@@ -442,7 +433,7 @@ class SnapshotHandler {
 
     /* Get the snapshot */
     $ldap_to->cat($dn);
-    $restoreObject = $ldap_to->fetch();
+    $ldap_to->fetch();
 
     /* Prepare import string */
     $data = gzuncompress($ldap_to->get_attribute($dn, 'gosaSnapshotData'));
@@ -450,7 +441,7 @@ class SnapshotHandler {
     /* Import the given data */
     try {
       $ldap->import_complete_ldif($data, FALSE, FALSE);
-    } catch(Exception $e) {
+    } catch (Exception $e) {
       msg_dialog::display(_('LDAP error'), $e->getMessage(), ERROR_DIALOG);
     }
     if (!$ldap->success()) {
diff --git a/include/class_config.inc b/include/class_config.inc
index 1ef785c1540fb1d185d6b590fb7a00a1148b3d5f..ca455a5203665c6342012509c65b512d87e8a624 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -1072,8 +1072,8 @@ class config  {
     /* Check if we have a current value for $name */
     if (isset($this->current[$name])) {
       $res = $this->current[$name];
-    /* Check if we have a global value for $name */
     } elseif (isset($this->data["MAIN"][$name])) {
+      /* Check if we have a global value for $name */
       $res = $this->data["MAIN"][$name];
     }
 
@@ -1372,7 +1372,7 @@ class config  {
     foreach ($this->data['CATEGORIES'] as $name => &$infos) {
       $infos['classes'] = array_unique($infos['classes']);
       if (!isset($infos['description'])) {
-        trigger_error("ACL category '$name' for classes ".join(',',$infos['classes'])." has no definition");
+        trigger_error("ACL category '$name' for classes ".join(',', $infos['classes'])." has no definition");
         $infos['description'] = $name;
         $infos['objectClass'] = array();
       }
diff --git a/include/class_divSelectBox.inc b/include/class_divSelectBox.inc
index 3a488f3d1b2de98442e76048e2060531af1c7f9a..378005ae77028ea1c084b2b72e31ad2f260aed70 100644
--- a/include/class_divSelectBox.inc
+++ b/include/class_divSelectBox.inc
@@ -180,7 +180,7 @@ class divSelectBox
       $cnt = 0;
 
       $this->cols = count($s_value);
-      foreach ($s_value as $s_key2 => $s_value2) {
+      foreach ($s_value as $s_value2) {
         $cnt++;
 
         if (!isset($s_value2['class'])) {
diff --git a/include/class_filterLDAP.inc b/include/class_filterLDAP.inc
index e40fbee105af44df084eeb10c82807bfd5a51de2..a3dbc9fa2d6c7b8ee40228002865a3fe30c01e23 100644
--- a/include/class_filterLDAP.inc
+++ b/include/class_filterLDAP.inc
@@ -51,11 +51,8 @@ class filterLDAP {
    */
   static function query($parent, $base, $scope, $filter, $attributes, $category, $objectStorage = array(""))
   {
-    $config = session::global_get('config');
-    $ldap   = $config->get_ldap_link(TRUE);
     $flag   = ($scope == "sub"?GL_SUBSEARCH:0);
-    $result = filterLDAP::get_list($parent, $base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
-    return $result;
+    return filterLDAP::get_list($parent, $base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
   }
 
   /*!
@@ -152,7 +149,7 @@ class filterLDAP {
       // In no-subsearch mode overwrite default method if
       // current base equals the initial base
       if ($base == $initial_base && !($flags & GL_SUBSEARCH)) {
-          $method = "ls";
+        $method = "ls";
       }
 
       if ($method == "ls") {
@@ -191,7 +188,7 @@ class filterLDAP {
               $result[] = $attrs;
             }
           } else {
-            //trigger_error("Invalid objectType given, please check listing.xml '{$dn}'!");
+            @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, "Invalid objectType given, please check listing.xml");
           }
         }
       }
diff --git a/include/class_listing.inc b/include/class_listing.inc
index b32704ef4efb61fa372b08800c8274b9ccfb4ecf..3a153d6c3ddfdb45c67745c108d2a1d8fc52c3af 100644
--- a/include/class_listing.inc
+++ b/include/class_listing.inc
@@ -229,9 +229,6 @@ class listing {
         'filter'      => ldapFilter::parse($i['filter']),
         'nameAttr'    => $i['nameAttr'],
       );
-      if (!isset($i['nameAttr'])) {
-        print_r($i);
-      }
     }
     $this->categories = array();
     if (isset($this->xmlData['definition']['objectType'])) {
@@ -1178,7 +1175,6 @@ class listing {
    */
   function getAction()
   {
-    global $config;
     // Do not do anything if this is not our PID, or there's even no PID available...
     if (!isset($_REQUEST['dn']) && (!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->pid)) {
       return;
diff --git a/include/class_management.inc b/include/class_management.inc
index d17388a8b757f8ab8c360f41f126e932ebe1b893..ac8a3cf95ec7235f804c8d03a60fb3c6677f0b3b 100644
--- a/include/class_management.inc
+++ b/include/class_management.inc
@@ -394,7 +394,7 @@ class management
     if (!empty($altTabType)) $tabType = $altTabType;
     if (!empty($altAclCategory)) $aclCategory = $altAclCategory;
 
-    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, "Entry removel confirmed!");
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, "Entry removal confirmed!");
 
     foreach ($this->dns as $dn) {
       // Check permissions, are we allowed to remove this object?
diff --git a/include/class_msg_dialog.inc b/include/class_msg_dialog.inc
index 599611ea2856831f7b2df53289600e9f3d1e9a00..88ca4b469434149f87aea5e96d44ef6a24e500bd 100644
--- a/include/class_msg_dialog.inc
+++ b/include/class_msg_dialog.inc
@@ -206,13 +206,9 @@ class msg_dialog
     $return     = "";
     $dialog_ids = "";
 
-    $seen = "";
-    /*if (isset($_POST['closed_msg_dialogs'])) {
-      $seen = $_POST['closed_msg_dialogs'];
-    }*/
-
-    if (session::is_set('msg_dialogs') && is_array(session::get('msg_dialogs')) && count(session::get('msg_dialogs'))) {
-
+    if (session::is_set('msg_dialogs') &&
+        is_array(session::get('msg_dialogs')) &&
+        count(session::get('msg_dialogs'))) {
       /* Get frame one */
       $smarty = get_smarty();
       $smarty->assign("frame", TRUE);
@@ -220,9 +216,7 @@ class msg_dialog
 
       $msg_dialogs = session::get('msg_dialogs');
       foreach ($msg_dialogs as $key => $dialog) {
-        if (preg_match("/".$dialog->get_ID()."/", $seen)) {
-          unset($msg_dialogs[$key]);
-        } else {
+        if (!preg_match("/".$dialog->get_ID()."/", "")) {
           $return     .= $dialog->execute();
           $dialog_ids = $dialog->get_ID().",".$dialog_ids;
         }
@@ -239,6 +233,5 @@ class msg_dialog
     }
     return $return;
   }
-
 }
 ?>
diff --git a/include/class_plugin.inc b/include/class_plugin.inc
index ce55d823d97a40e1e24b1a5111f2bd26d7b5ed5c..e4bab7c00e15a897dfceec83a1f079a62d9989a3 100644
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
@@ -1714,7 +1714,6 @@ class plugin
   */
   function get_allowed_bases()
   {
-    $ui = get_userinfo();
     $deps = array();
 
     /* Is this a new object ? Or just an edited existing object */
@@ -1735,9 +1734,7 @@ class plugin
     /* Add current base */
     if (isset($this->base) && isset($this->config->idepartments[$this->base])) {
       $deps[$this->base] = $this->config->idepartments[$this->base];
-    } elseif (strtolower($this->dn) == strtolower($this->config->current['BASE'])) {
-
-    } else {
+    } elseif (strtolower($this->dn) != strtolower($this->config->current['BASE'])) {
       trigger_error("Cannot return list of departments, no default base found in class ".get_class($this).". (base is '".$this->base."')");
     }
     return $deps;
diff --git a/include/class_tabs.inc b/include/class_tabs.inc
index dd03e26fbd5e855895f7dc71c8d04e9e3314c699..6a444c59293243c41a31bfea9b699cceaa42aaf3 100644
--- a/include/class_tabs.inc
+++ b/include/class_tabs.inc
@@ -222,9 +222,9 @@ class tabs
     if (!$disabled) {
       $display .= '<input type="hidden" name="arg" value=""/>';
     }
-    $display .= '<table class="tabs_header"><tbody><tr>';
-    $index = 0;
-    $style = array("tab_left", "tab_active", "tab_near_active", "tab_right");
+    $display  .= '<table class="tabs_header"><tbody><tr>';
+    $index    = 0;
+    $style    = array("tab_left", "tab_active", "tab_near_active", "tab_right");
     foreach ($this->by_name as $class => $name) {
 
       /* Activate right tabs with style "tab_right"
@@ -270,8 +270,8 @@ class tabs
       }
     }
 
-    $display.= "<td>\n";
-    $display.= "<div class=\"tab_border\">&nbsp;</div></td></tr></tbody></table>";
+    $display .= "<td>\n";
+    $display .= "<div class=\"tab_border\">&nbsp;</div></td></tr></tbody></table>";
 
     return $display;
   }
diff --git a/include/class_tests.inc b/include/class_tests.inc
index 4e4402f65894691d9a0de060b3d3004a9b0781c9..d5758b7dc46ccbc83d152d377dfcd4d50822ca5e 100644
--- a/include/class_tests.inc
+++ b/include/class_tests.inc
@@ -374,13 +374,11 @@ class tests {
    */
   public static function is_date($date)
   {
-    global $lang;
-
     if ($date == "") {
       return TRUE;
     }
 
-    //TODO: use $lang to check date format
+    //TODO: use global $lang to check date format
     if (!preg_match("/([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})/", $date, $matches)) {
       return FALSE;
     }
diff --git a/include/functions_debug.inc b/include/functions_debug.inc
index e9f1cdcbf10744b52f493e8b987ebbdc5023083d..537331e0e5fc6272aae0d3ea811fc6aee45baeb2 100644
--- a/include/functions_debug.inc
+++ b/include/functions_debug.inc
@@ -183,7 +183,6 @@ class Print_a_class {
       $this->output .= '</td>';
       $this->output .= '<td nowrap="nowrap" style="background-color:#'.$this->value_bg_color.';font: '.$this->fontsize.' '.$this->fontfamily.'; color:black;">';
 
-
       // value output
       if ($type == 'array') {
         if (count($value)) {
diff --git a/include/php_setup.inc b/include/php_setup.inc
index 329aab559f06ec1cc5c4594a97331c05a81c8643..9f6ceb75becdcd9c10a7e5684cebbf1219a6763e 100644
--- a/include/php_setup.inc
+++ b/include/php_setup.inc
@@ -274,7 +274,6 @@ ini_set("include_path", ".:$BASE_DIR/include:".PHP_DIR.":".PEAR_DIR);
 /* Do smarty setup */
 require(SMARTY);
 
-/*require(SMARTY_PATH);*/
 $smarty = new Smarty;
 
 $smarty->template_dir = $BASE_DIR.'/ihtml/';