diff --git a/include/class_config.inc b/include/class_config.inc
index 08d5f24960961d556a902b166817faff053d2bb8..25b01398ec6be48dd8448c8190b1eef76cd1eb30 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -293,11 +293,12 @@ class config  {
           session::global_set('HTTP_FDKEY_CACHE', $cache);
         } catch (Exception $e) {
           $msg = sprintf(
-            _('It seems you are trying to decode something which is not encoded : %s<br/>\n'.
+            _('It seems you are trying to decode something which is not encoded : %s<br/>'."\n".
               'Please check you are not using a fusiondirectory.secrets file while your passwords are not encrypted.'),
             $e->getMessage()
           );
-          msg_dialog::display(_("Configuration error"), $msg, FATAL_ERROR_DIALOG);
+          msg_dialog::display(_('Configuration error'), $msg, FATAL_ERROR_DIALOG);
+          exit;
         }
       }
       return $cache[$creds];
@@ -368,6 +369,10 @@ class config  {
    */
   function set_current($name)
   {
+    if (!isset($this->data['LOCATIONS'][$name])) {
+      msg_dialog::display(_('Error'), sprintf(_('Location "%s" could not be found in the configuration file'), $name), FATAL_ERROR_DIALOG);
+      exit;
+    }
     $this->current = $this->data['LOCATIONS'][$name];
 
     if (isset($this->current['INITIAL_BASE'])) {
diff --git a/include/class_session.inc b/include/class_session.inc
index ddc47593a644e65f1c65c36224cabdf0ffbc19c8..72bf901508bd08390a109398ec6b10b34e93f0f6 100644
--- a/include/class_session.inc
+++ b/include/class_session.inc
@@ -48,6 +48,7 @@ class session {
     /* Sanity check */
     if (!session::channel_exists($channel)) {
       msg_dialog::display(_("Internal error"), _("Requested channel does not exist! Please contact your Administrator."), FATAL_ERROR_DIALOG);
+      exit;
     }
 
     $channel = "gch_".$channel;
@@ -85,6 +86,7 @@ class session {
       /* Sanity check */
       if (!session::channel_exists($channel)) {
         msg_dialog::display(_("Internal error"), _("Requested channel does not exist! Please contact your Administrator."), FATAL_ERROR_DIALOG);
+        exit;
       }
       $_SESSION[$channel][$name] = $value;
     }
@@ -123,6 +125,7 @@ class session {
     /* Sanity check */
     if (!session::channel_exists($channel)) {
       msg_dialog::display(_("Internal error"), _("Requested channel does not exist! Please contact your Administrator."), FATAL_ERROR_DIALOG);
+      exit;
     }
 
     $channel  = "gch_".$channel;