diff --git a/docs/simplesamlphp-advancedfeatures.md b/docs/simplesamlphp-advancedfeatures.md
index 5bf8d163ab3c017cc4db54d6ccb11f4f05463975..adb7c2486569474a69930c1dc1117b1b3de6fbfc 100644
--- a/docs/simplesamlphp-advancedfeatures.md
+++ b/docs/simplesamlphp-advancedfeatures.md
@@ -127,7 +127,7 @@ Example code for the function with GeoIP country check:
         }
 
         if ($init) {
-            $session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+            $session->setData($data_type, $data_key, $remote_addr, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
             return;
         }
 
@@ -147,7 +147,7 @@ Example code for the function with GeoIP country check:
 
         if ($country_a === $country_b) {
             if ($stored_remote_addr !== $remote_addr) {
-                $session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+                $session->setData($data_type, $data_key, $remote_addr, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
             }
 
             return TRUE;
diff --git a/docs/simplesamlphp-maintenance.md b/docs/simplesamlphp-maintenance.md
index ab38566e94330c607808a0b5218889247e3b5b2b..02e43b4f6e4aecaeb4c8c657262e7f6bcf0f6b52 100644
--- a/docs/simplesamlphp-maintenance.md
+++ b/docs/simplesamlphp-maintenance.md
@@ -52,7 +52,7 @@ SimpleSAMLphp as an Identity Provider, or any other applications using it are no
 settings by leaving these options unset or setting them to `null`.
 
 If you need to restore your session's application after calling SimpleSAMLphp, you can do it by calling the `cleanup()` method of the
-`SimpleSAML_Session` class, like described [here](simplesamlphp-sp#section_6).
+`\SimpleSAML\Session` class, like described [here](simplesamlphp-sp#section_6).
 
 ### Configuring memcache
 
diff --git a/docs/simplesamlphp-sp.md b/docs/simplesamlphp-sp.md
index dd50adab9a7c5435d95b5b24e5a6e079c70287b1..453b9b525101a2b2b10c3008c8de62df75a82b4e 100644
--- a/docs/simplesamlphp-sp.md
+++ b/docs/simplesamlphp-sp.md
@@ -191,7 +191,7 @@ If we are using PHP sessions in SimpleSAMLphp and in the application we are prot
 existing session when invoked for the first time, and its own session will prevail afterwards. If you want to restore
 your own session after calling SimpleSAMLphp, you can do so by cleaning up the session like this:
 
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $session = \SimpleSAML\Session::getSessionFromRequest();
     $session->cleanup();
 
 If you don't cleanup SimpleSAMLphp's session and try to use $_SESSION afterwards, you won't be using your own session
diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index 17ad9c38e575ebf497d7eb6d175418225d367fb4..e50959bfaf162a2dfe2045b7113883c84e4ab880 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -11,10 +11,9 @@
  *
  * @deprecated This class will be removed in SSP 2.0.
  */
+
 class SimpleSAML_Auth_Default
 {
-
-
     /**
      * @deprecated This method will be removed in SSP 2.0. Use SimpleSAML_Auth_Source::initLogin() instead.
      */
@@ -58,7 +57,7 @@ class SimpleSAML_Auth_Default
         assert(is_string($returnURL));
         assert(is_string($authority));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         $state = $session->getAuthData($authority, 'LogoutState');
         $session->doLogout($authority);
diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index bdc0871acf862703b1a4460ed2714a1ffc6ec5bb..8c464778a85dd8ab8034afe46b6336d61e4f09df 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -7,7 +7,7 @@ use \SimpleSAML_Auth_State as State;
 use \SimpleSAML\Configuration;
 use \SimpleSAML_Error_AuthSource as AuthSourceError;
 use \SimpleSAML\Module;
-use \SimpleSAML_Session as Session;
+use \SimpleSAML\Session;
 use \SimpleSAML\Utils\HTTP;
 
 /**
@@ -15,9 +15,9 @@ use \SimpleSAML\Utils\HTTP;
  *
  * @package SimpleSAMLphp
  */
+
 class Simple
 {
-
     /**
      * The id of the authentication source we are accessing.
      *
@@ -242,7 +242,7 @@ class Simple
                 $stateID = State::saveState($state, $state['ReturnStateStage']);
                 $params[$state['ReturnStateParam']] = $stateID;
             }
-            \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnTo'], $params);
+            HTTP::redirectTrustedURL($state['ReturnTo'], $params);
         }
     }
 
diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php
index 1efb0fae5b6f96cee0b0eaf0b789dff4cbe7ccd6..e1f4043d2bf0aae0a0b6767c01e4420bf26ba9c0 100644
--- a/lib/SimpleSAML/Auth/Source.php
+++ b/lib/SimpleSAML/Auth/Source.php
@@ -10,6 +10,7 @@ use SimpleSAML\Auth\SourceFactory;
  * @author Olav Morken, UNINETT AS.
  * @package SimpleSAMLphp
  */
+
 abstract class SimpleSAML_Auth_Source
 {
     /**
@@ -114,7 +115,7 @@ abstract class SimpleSAML_Auth_Source
         assert(isset($state['ReturnCallback']));
 
         // the default implementation just copies over the previous authentication data
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $data = $session->getAuthState($this->authId);
         foreach ($data as $k => $v) {
             $state[$k] = $v;
@@ -218,7 +219,7 @@ abstract class SimpleSAML_Auth_Source
         $return = $state['SimpleSAML_Auth_Source.Return'];
 
         // save session state
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authId = $state['SimpleSAML_Auth_Source.id'];
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
@@ -381,7 +382,7 @@ abstract class SimpleSAML_Auth_Source
 
         $source = $state['SimpleSAML_Auth_Source.logoutSource'];
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         if (!$session->isValid($source)) {
             SimpleSAML\Logger::warning(
                 'Received logout from an invalid authentication source '.
@@ -430,12 +431,12 @@ abstract class SimpleSAML_Auth_Source
             'state'    => $callbackState,
         );
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData(
             'SimpleSAML_Auth_Source.LogoutCallbacks',
             $id,
             $data,
-            SimpleSAML_Session::DATA_TIMEOUT_SESSION_END
+            \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END
         );
     }
 
@@ -456,7 +457,7 @@ abstract class SimpleSAML_Auth_Source
 
         $id = strlen($this->authId).':'.$this->authId.$assoc;
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         $data = $session->getData('SimpleSAML_Auth_Source.LogoutCallbacks', $id);
         if ($data === null) {
diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index 0e6d451e50b2fc9af6a52005c90350aa8320602f..ff9014815231b861d83119fad1cabf79cadb6b02 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -1,6 +1,5 @@
 <?php
 
-
 /**
  * This is a helper class for saving and loading state information.
  *
@@ -30,8 +29,6 @@
  */
 class SimpleSAML_Auth_State
 {
-
-
     /**
      * The index in the state array which contains the identifier.
      */
@@ -205,7 +202,7 @@ class SimpleSAML_Auth_State
 
         // Save state
         $serializedState = serialize($state);
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData('SimpleSAML_Auth_State', $id, $serializedState, self::getStateTimeout());
 
         SimpleSAML\Logger::debug('Saved state: '.var_export($return, true));
@@ -265,7 +262,7 @@ class SimpleSAML_Auth_State
 
         $sid = self::parseStateID($id);
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $state = $session->getData('SimpleSAML_Auth_State', $sid['id']);
 
         if ($state === null) {
@@ -327,7 +324,7 @@ class SimpleSAML_Auth_State
 
         SimpleSAML\Logger::debug('Deleting state: '.var_export($state[self::ID], true));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->deleteData('SimpleSAML_Auth_State', $state[self::ID]);
     }
 
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index b192935d922ff28b43a4728ed041f6b3d86e13f8..aceac89f95a8e2d033f807aa0199c266d817e629 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -205,7 +205,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
         SimpleSAML\Logger::error('Error report with id '.$reportId.' generated.');
 
         $config = \SimpleSAML\Configuration::getInstance();
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
 
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referer = $_SERVER['HTTP_REFERER'];
@@ -268,7 +268,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception
         }
 
         $data['email'] = '';
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authorities = $session->getAuthorities();
         foreach ($authorities as $authority) {
             $attributes = $session->getAuthData($authority, 'Attributes');
diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php
index fc5abfc720897e9c474ab9d7eac636f0e881aada..5fd3f41d90d632162ad14cb6bf29c662c27af93e 100644
--- a/lib/SimpleSAML/IdP.php
+++ b/lib/SimpleSAML/IdP.php
@@ -216,7 +216,7 @@ class SimpleSAML_IdP
 
         $association['core:IdP'] = $this->id;
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->addAssociation($this->associationGroup, $association);
     }
 
@@ -228,7 +228,7 @@ class SimpleSAML_IdP
      */
     public function getAssociations()
     {
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         return $session->getAssociations($this->associationGroup);
     }
 
@@ -242,7 +242,7 @@ class SimpleSAML_IdP
     {
         assert(is_string($assocId));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->terminateAssociation($this->associationGroup, $assocId);
     }
 
@@ -268,12 +268,12 @@ class SimpleSAML_IdP
         assert(is_callable($state['Responder']));
 
         if (isset($state['core:SP'])) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->setData(
                 'core:idp-ssotime',
                 $state['core:IdP'].';'.$state['core:SP'],
                 time(),
-                SimpleSAML_Session::DATA_TIMEOUT_SESSION_END
+                \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END
             );
         }
 
@@ -306,7 +306,7 @@ class SimpleSAML_IdP
         }
 
         if (isset($state['core:SP'])) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $previousSSOTime = $session->getData('core:idp-ssotime', $state['core:IdP'].';'.$state['core:SP']);
             if ($previousSSOTime !== null) {
                 $state['PreviousSSOTimestamp'] = $previousSSOTime;
@@ -479,7 +479,7 @@ class SimpleSAML_IdP
 
         if ($assocId !== null) {
             $this->terminateAssociation($assocId);
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->deleteData('core:idp-ssotime', $this->id.':'.$state['saml:SPEntityId']);
         }
 
@@ -509,7 +509,7 @@ class SimpleSAML_IdP
         assert(is_string($assocId));
         assert(is_string($relayState) || $relayState === null);
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->deleteData('core:idp-ssotime', $this->id.';'.substr($assocId, strpos($assocId, ':') + 1));
 
         $handler = $this->getLogoutHandler();
diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php
index f98451de3fcec8f0d0010f0d168160afd8b97c84..3c569a1faf9eee0c94975ade725f50e0ede194db 100644
--- a/lib/SimpleSAML/Logger.php
+++ b/lib/SimpleSAML/Logger.php
@@ -12,7 +12,6 @@ namespace SimpleSAML;
  */
 class Logger
 {
-
     /**
      * @var \SimpleSAML\Logger\LoggingHandlerInterface|false|null
      */
@@ -266,11 +265,11 @@ class Logger
     public static function flush()
     {
         try {
-            $s = \SimpleSAML_Session::getSessionFromRequest();
+            $s = Session::getSessionFromRequest();
         } catch (\Exception $e) {
             // loading session failed. We don't care why, at this point we have a transient session, so we use that
             self::error('Cannot load or create session: '.$e->getMessage());
-            $s = \SimpleSAML_Session::getSessionFromRequest();
+            $s = Session::getSessionFromRequest();
         }
         self::$trackid = $s->getTrackID();
 
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 91af0e5a883059ce77488b537216e17b132df73d..0f33aaaaded35df0c656b25561aeeb3d9294a6db 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -1,4 +1,7 @@
 <?php
+
+namespace SimpleSAML;
+
 /**
  * The Session class holds information about a user session, and everything attached to it.
  *
@@ -16,9 +19,9 @@
  * @author Jaime Pérez Crespo, UNINETT AS <jaime.perez@uninett.no>
  * @package SimpleSAMLphp
  */
-class SimpleSAML_Session implements Serializable
-{
 
+class Session implements \Serializable
+{
     /**
      * This is a timeout value for setData, which indicates that the data
      * should never be deleted, i.e. lasts the whole session lifetime.
@@ -39,7 +42,7 @@ class SimpleSAML_Session implements Serializable
     /**
      * This variable holds the instance of the session - Singleton approach.
      *
-     * Warning: do not set the instance manually, call SimpleSAML_Session::load() instead.
+     * Warning: do not set the instance manually, call \SimpleSAML\Session::load() instead.
      */
     private static $instance = null;
 
@@ -144,15 +147,15 @@ class SimpleSAML_Session implements Serializable
     {
         if (php_sapi_name() === 'cli' || defined('STDIN')) {
             $this->trackid = 'CL'.bin2hex(openssl_random_pseudo_bytes(4));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
             $this->transient = $transient;
             return;
         }
 
         if ($transient) { // transient session
-            $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+            $sh = SessionHandler::getSessionHandler();
             $this->trackid = 'TR'.bin2hex(openssl_random_pseudo_bytes(4));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
             $this->transient = true;
 
             /*
@@ -164,18 +167,18 @@ class SimpleSAML_Session implements Serializable
                 $this->sessionId = $sh->newSessionId();
             }
         } else { // regular session
-            $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+            $sh = SessionHandler::getSessionHandler();
             $this->sessionId = $sh->newSessionId();
             $sh->setCookie($sh->getSessionCookieName(), $this->sessionId, $sh->getCookieParams());
 
 
             $this->trackid = bin2hex(openssl_random_pseudo_bytes(5));
-            SimpleSAML\Logger::setTrackId($this->trackid);
+            Logger::setTrackId($this->trackid);
 
             $this->markDirty();
 
             // initialize data for session check function if defined
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $checkFunction = $globalConfig->getArray('session.check_function', null);
             if (isset($checkFunction)) {
                 assert(is_callable($checkFunction));
@@ -235,8 +238,8 @@ class SimpleSAML_Session implements Serializable
     /**
      * Retrieves the current session. Creates a new session if there's not one.
      *
-     * @return SimpleSAML_Session The current session.
-     * @throws Exception When session couldn't be initialized and the session fallback is disabled by configuration.
+     * @return \SimpleSAML\Session The current session.
+     * @throws \Exception When session couldn't be initialized and the session fallback is disabled by configuration.
      */
     public static function getSessionFromRequest()
     {
@@ -249,18 +252,18 @@ class SimpleSAML_Session implements Serializable
         $session = null;
         try {
             $session = self::getSession();
-        } catch (Exception $e) {
+        } catch (\Exception $e) {
             /*
              * For some reason, we were unable to initialize this session. Note that this error might be temporary, and
              * it's possible that we can recover from it in subsequent requests, so we should not try to create a new
              * session here. Therefore, use just a transient session and throw the exception for someone else to handle
              * it.
              */
-            SimpleSAML\Logger::error('Error loading session: '.$e->getMessage());
+            Logger::error('Error loading session: '.$e->getMessage());
             self::useTransientSession();
-            if ($e instanceof SimpleSAML_Error_Exception) {
+            if ($e instanceof \SimpleSAML_Error_Exception) {
                 $cause = $e->getCause();
-                if ($cause instanceof Exception) {
+                if ($cause instanceof \Exception) {
                     throw $cause;
                 }
             }
@@ -268,7 +271,7 @@ class SimpleSAML_Session implements Serializable
         }
 
         // if getSession() found it, use it
-        if ($session instanceof SimpleSAML_Session) {
+        if ($session instanceof Session) {
             return self::load($session);
         }
 
@@ -284,20 +287,20 @@ class SimpleSAML_Session implements Serializable
 
         // try to create a new session
         try {
-            self::load(new SimpleSAML_Session());
-        } catch (\SimpleSAML\Error\CannotSetCookie $e) {
+            self::load(new Session());
+        } catch (Error\CannotSetCookie $e) {
             // can't create a regular session because we can't set cookies. Use transient.
-            $c = \SimpleSAML\Configuration::getInstance();
+            $c = Configuration::getInstance();
             self::useTransientSession();
 
-            if ($e->getCode() === \SimpleSAML\Error\CannotSetCookie::SECURE_COOKIE) {
-                throw new \SimpleSAML\Error\CriticalConfigurationError(
+            if ($e->getCode() === Error\CannotSetCookie::SECURE_COOKIE) {
+                throw new Error\CriticalConfigurationError(
                     $e->getMessage(),
                     null,
                     $c->toArray()
                 );
             }
-            SimpleSAML\Logger::error('Error creating session: '.$e->getMessage());
+            Logger::error('Error creating session: '.$e->getMessage());
         }
 
         // we must have a session now, either regular or transient
@@ -309,14 +312,14 @@ class SimpleSAML_Session implements Serializable
      *
      * @param string|null $sessionId The session we should get, or null to get the current session.
      *
-     * @return SimpleSAML_Session|null The session that is stored in the session handler, or null if the session wasn't
+     * @return \SimpleSAML\Session|null The session that is stored in the session handler, or null if the session wasn't
      * found.
      */
     public static function getSession($sessionId = null)
     {
         assert(is_string($sessionId) || $sessionId === null);
 
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
 
         if ($sessionId === null) {
             $checkToken = true;
@@ -340,7 +343,7 @@ class SimpleSAML_Session implements Serializable
         assert($session instanceof self);
 
         if ($checkToken) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
 
             if ($session->authToken !== null) {
                 $authTokenCookieName = $globalConfig->getString(
@@ -348,11 +351,11 @@ class SimpleSAML_Session implements Serializable
                     'SimpleSAMLAuthToken'
                 );
                 if (!isset($_COOKIE[$authTokenCookieName])) {
-                    SimpleSAML\Logger::warning('Missing AuthToken cookie.');
+                    Logger::warning('Missing AuthToken cookie.');
                     return null;
                 }
-                if (!SimpleSAML\Utils\Crypto::secureCompare($session->authToken, $_COOKIE[$authTokenCookieName])) {
-                    SimpleSAML\Logger::warning('Invalid AuthToken cookie.');
+                if (!Utils\Crypto::secureCompare($session->authToken, $_COOKIE[$authTokenCookieName])) {
+                    Logger::warning('Invalid AuthToken cookie.');
                     return null;
                 }
             }
@@ -363,7 +366,7 @@ class SimpleSAML_Session implements Serializable
                 assert(is_callable($checkFunction));
                 $check = call_user_func($checkFunction, $session);
                 if ($check !== true) {
-                    SimpleSAML\Logger::warning('Session did not pass check function.');
+                    Logger::warning('Session did not pass check function.');
                     return null;
                 }
             }
@@ -382,12 +385,12 @@ class SimpleSAML_Session implements Serializable
      *
      * Warning: never set self::$instance yourself, call this method instead.
      *
-     * @param SimpleSAML_Session $session The session to load.
-     * @return SimpleSAML_Session The session we just loaded, just for convenience.
+     * @param \SimpleSAML\Session $session The session to load.
+     * @return \SimpleSAML\Session The session we just loaded, just for convenience.
      */
-    private static function load(SimpleSAML_Session $session)
+    private static function load(Session $session)
     {
-        SimpleSAML\Logger::setTrackId($session->getTrackID());
+        Logger::setTrackId($session->getTrackID());
         self::$instance = $session;
         return self::$instance;
     }
@@ -405,7 +408,7 @@ class SimpleSAML_Session implements Serializable
             return;
         }
 
-        self::load(new SimpleSAML_Session(true));
+        self::load(new Session(true));
     }
 
     /**
@@ -437,15 +440,15 @@ class SimpleSAML_Session implements Serializable
         $this->dirty = false;
         $this->callback_registered = false;
 
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
 
         try {
             $sh->saveSession($this);
-        } catch (Exception $e) {
-            if (!($e instanceof SimpleSAML_Error_Exception)) {
-                $e = new SimpleSAML_Error_UnserializableException($e);
+        } catch (\Exception $e) {
+            if (!($e instanceof \SimpleSAML_Error_Exception)) {
+                $e = new \SimpleSAML_Error_UnserializableException($e);
             }
-            SimpleSAML\Logger::error('Unable to save session.');
+            Logger::error('Unable to save session.');
             $e->logError();
         }
     }
@@ -460,8 +463,8 @@ class SimpleSAML_Session implements Serializable
     public function cleanup()
     {
         $this->save();
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
-        if ($sh instanceof \SimpleSAML\SessionHandlerPHP) {
+        $sh = SessionHandler::getSessionHandler();
+        if ($sh instanceof SessionHandlerPHP) {
             $sh->restorePrevious();
         }
     }
@@ -550,7 +553,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_int($expire) || $expire === null);
 
         if ($expire === null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $expire = time() + $globalConfig->getInteger('session.rememberme.lifetime', 14 * 86400);
         }
         $this->rememberMeExpire = $expire;
@@ -574,7 +577,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_string($authority));
         assert(is_array($data) || $data === null);
 
-        SimpleSAML\Logger::debug('Session: doLogin("'.$authority.'")');
+        Logger::debug('Session: doLogin("'.$authority.'")');
 
         $this->markDirty();
 
@@ -589,7 +592,7 @@ class SimpleSAML_Session implements Serializable
 
         $data['Authority'] = $authority;
 
-        $globalConfig = \SimpleSAML\Configuration::getInstance();
+        $globalConfig = Configuration::getInstance();
         if (!isset($data['AuthnInstant'])) {
             $data['AuthnInstant'] = time();
         }
@@ -625,8 +628,8 @@ class SimpleSAML_Session implements Serializable
 
         $this->authData[$authority] = $data;
 
-        $this->authToken = SimpleSAML\Utils\Random::generateID();
-        $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
+        $this->authToken = Utils\Random::generateID();
+        $sessionHandler = SessionHandler::getSessionHandler();
 
         if (!$this->transient && (!empty($data['RememberMe']) || $this->rememberMeExpire) &&
             $globalConfig->getBoolean('session.rememberme.enable', false)
@@ -634,12 +637,12 @@ class SimpleSAML_Session implements Serializable
             $this->setRememberMeExpire();
         } else {
             try {
-                SimpleSAML\Utils\HTTP::setCookie(
+                Utils\HTTP::setCookie(
                     $globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
                     $this->authToken,
                     $sessionHandler->getCookieParams()
                 );
-            } catch (SimpleSAML\Error\CannotSetCookie $e) {
+            } catch (Error\CannotSetCookie $e) {
                 /*
                  * Something went wrong when setting the auth token. We cannot recover from this, so we better log a
                  * message and throw an exception. The user is not properly logged in anyway, so clear all login
@@ -647,7 +650,7 @@ class SimpleSAML_Session implements Serializable
                  */
                 unset($this->authToken);
                 unset($this->authData[$authority]);
-                \SimpleSAML\Logger::error('Cannot set authentication token cookie: '.$e->getMessage());
+                Logger::error('Cannot set authentication token cookie: '.$e->getMessage());
                 throw $e;
             }
         }
@@ -662,10 +665,10 @@ class SimpleSAML_Session implements Serializable
      */
     public function doLogout($authority)
     {
-        SimpleSAML\Logger::debug('Session: doLogout('.var_export($authority, true).')');
+        Logger::debug('Session: doLogout('.var_export($authority, true).')');
 
         if (!isset($this->authData[$authority])) {
-            SimpleSAML\Logger::debug('Session: Already logged out of '.$authority.'.');
+            Logger::debug('Session: Already logged out of '.$authority.'.');
             return;
         }
 
@@ -685,7 +688,7 @@ class SimpleSAML_Session implements Serializable
      *
      * @param string $authority The authentication source we are logging out from.
      *
-     * @throws Exception If the handler is not a valid function or method.
+     * @throws \Exception If the handler is not a valid function or method.
      */
     private function callLogoutHandlers($authority)
     {
@@ -701,7 +704,7 @@ class SimpleSAML_Session implements Serializable
                 $classname = $handler[0];
                 $functionname = $handler[1];
 
-                throw new Exception(
+                throw new \Exception(
                     'Logout handler is not a valid function: '.$classname.'::'.
                     $functionname
                 );
@@ -728,7 +731,7 @@ class SimpleSAML_Session implements Serializable
         assert(is_string($authority));
 
         if (!isset($this->authData[$authority])) {
-            SimpleSAML\Logger::debug(
+            Logger::debug(
                 'Session: '.var_export($authority, true).
                 ' not valid because we are not authenticated.'
             );
@@ -736,11 +739,11 @@ class SimpleSAML_Session implements Serializable
         }
 
         if ($this->authData[$authority]['Expire'] <= time()) {
-            SimpleSAML\Logger::debug('Session: '.var_export($authority, true).' not valid because it is expired.');
+            Logger::debug('Session: '.var_export($authority, true).' not valid because it is expired.');
             return false;
         }
 
-        SimpleSAML\Logger::debug('Session: Valid session found with '.var_export($authority, true).'.');
+        Logger::debug('Session: Valid session found with '.var_export($authority, true).'.');
 
         return true;
     }
@@ -754,7 +757,7 @@ class SimpleSAML_Session implements Serializable
     {
         assert(is_null($params) || is_array($params));
 
-        $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sessionHandler = SessionHandler::getSessionHandler();
 
         if ($this->sessionId !== null) {
             $sessionHandler->setCookie($sessionHandler->getSessionCookieName(), $this->sessionId, $params);
@@ -763,8 +766,8 @@ class SimpleSAML_Session implements Serializable
         $params = array_merge($sessionHandler->getCookieParams(), is_array($params) ? $params : array());
 
         if ($this->authToken !== null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
-            \SimpleSAML\Utils\HTTP::setCookie(
+            $globalConfig = Configuration::getInstance();
+            Utils\HTTP::setCookie(
                 $globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
                 $this->authToken,
                 $params
@@ -786,7 +789,7 @@ class SimpleSAML_Session implements Serializable
         $this->markDirty();
 
         if ($expire === null) {
-            $globalConfig = \SimpleSAML\Configuration::getInstance();
+            $globalConfig = Configuration::getInstance();
             $expire = time() + $globalConfig->getInteger('session.duration', 8 * 60 * 60);
         }
 
@@ -800,7 +803,7 @@ class SimpleSAML_Session implements Serializable
      * @param string $classname The class which contains the logout handler.
      * @param string $functionname The logout handler function.
      *
-     * @throws Exception If the handler is not a valid function or method.
+     * @throws \Exception If the handler is not a valid function or method.
      */
     public function registerLogoutHandler($authority, $classname, $functionname)
     {
@@ -809,7 +812,7 @@ class SimpleSAML_Session implements Serializable
         $logout_handler = array($classname, $functionname);
 
         if (!is_callable($logout_handler)) {
-            throw new Exception(
+            throw new \Exception(
                 'Logout handler is not a vaild function: '.$classname.'::'.
                 $functionname
             );
@@ -847,7 +850,7 @@ class SimpleSAML_Session implements Serializable
     /**
      * This function stores data in the data store.
      *
-     * The timeout value can be SimpleSAML_Session::DATA_TIMEOUT_SESSION_END, which indicates
+     * The timeout value can be \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END, which indicates
      * that the data should never be deleted.
      *
      * @param string   $type The type of the data. This is checked when retrieving data from the store.
@@ -857,7 +860,7 @@ class SimpleSAML_Session implements Serializable
      * This parameter is optional. The default value is set in 'session.datastore.timeout',
      * and the default is 4 hours.
      *
-     * @throws Exception If the data couldn't be stored.
+     * @throws \Exception If the data couldn't be stored.
      *
      */
     public function setData($type, $id, $data, $timeout = null)
@@ -871,12 +874,12 @@ class SimpleSAML_Session implements Serializable
 
         if ($timeout === null) {
             // use the default timeout
-            $configuration = \SimpleSAML\Configuration::getInstance();
+            $configuration = Configuration::getInstance();
 
             $timeout = $configuration->getInteger('session.datastore.timeout', null);
             if ($timeout !== null) {
                 if ($timeout <= 0) {
-                    throw new Exception(
+                    throw new \Exception(
                         'The value of the session.datastore.timeout'.
                         ' configuration option should be a positive integer.'
                     );
@@ -1036,7 +1039,7 @@ class SimpleSAML_Session implements Serializable
      */
     public function hasSessionCookie()
     {
-        $sh = \SimpleSAML\SessionHandler::getSessionHandler();
+        $sh = SessionHandler::getSessionHandler();
         return $sh->hasSessionCookie();
     }
 
diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php
index 4608e3cb609ee007ca4ad163dd42a52632aef056..945a75d6ac032e5cbee24b97ef52413904cd61a8 100644
--- a/lib/SimpleSAML/SessionHandler.php
+++ b/lib/SimpleSAML/SessionHandler.php
@@ -82,9 +82,9 @@ abstract class SessionHandler
     /**
      * Save the session.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    abstract public function saveSession(\SimpleSAML_Session $session);
+    abstract public function saveSession(Session $session);
 
 
     /**
@@ -92,7 +92,7 @@ abstract class SessionHandler
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      */
     abstract public function loadSession($sessionId = null);
 
@@ -129,7 +129,7 @@ abstract class SessionHandler
      */
     private static function createSessionHandler()
     {
-        $store = \SimpleSAML\Store::getInstance();
+        $store = Store::getInstance();
         if ($store === false) {
             self::$sessionHandler = new SessionHandlerPHP();
         } else {
diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php
index c0bb2e8dfc450c0c333fb793ca5f2a99597c7450..a9995081b0cdf7752b50dff2b0c7068535895259 100644
--- a/lib/SimpleSAML/SessionHandlerCookie.php
+++ b/lib/SimpleSAML/SessionHandlerCookie.php
@@ -57,7 +57,7 @@ abstract class SessionHandlerCookie extends SessionHandler
     public function newSessionId()
     {
         $this->session_id = self::createSessionID();
-        \SimpleSAML_Session::createSession($this->session_id);
+        Session::createSession($this->session_id);
 
         return $this->session_id;
     }
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 8b0904dabb552ec5cccb2130b9331b93a3f09699..b17796caf39d69822bc0f15c623068663bdf7b3d 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -125,7 +125,7 @@ class SessionHandlerPHP extends SessionHandler
      * Use this method to restore a previous PHP session existing before SimpleSAMLphp initialized its own session.
      *
      * WARNING: do not use this method directly, unless you know what you are doing. Calling this method directly,
-     * outside of SimpleSAML_Session, could cause SimpleSAMLphp's session to be lost or mess the application's one. The
+     * outside of \SimpleSAML\Session, could cause SimpleSAMLphp's session to be lost or mess the application's one. The
      * session must always be saved properly before calling this method. If you don't understand what this is about,
      * don't use this method.
      */
@@ -168,7 +168,7 @@ class SessionHandlerPHP extends SessionHandler
     {
         // generate new (secure) session id
         $sessionId = bin2hex(openssl_random_pseudo_bytes(16));
-        \SimpleSAML_Session::createSession($sessionId);
+        Session::createSession($sessionId);
 
         return $sessionId;
     }
@@ -215,9 +215,9 @@ class SessionHandlerPHP extends SessionHandler
     /**
      * Save the current session to the PHP session array.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    public function saveSession(\SimpleSAML_Session $session)
+    public function saveSession(\SimpleSAML\Session $session)
     {
         $_SESSION['SimpleSAMLphp_SESSION'] = serialize($session);
     }
@@ -228,7 +228,7 @@ class SessionHandlerPHP extends SessionHandler
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      *
      * @throws \SimpleSAML_Error_Exception If it wasn't possible to disable session cookies or we are trying to load a
      * PHP session with a specific identifier and it doesn't match with the current session identifier.
diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php
index 108655641903a2c9accb4074032b2a6d9042f27f..f40b9eb958c6c1871c4fbbc2629412876c30a006 100644
--- a/lib/SimpleSAML/SessionHandlerStore.php
+++ b/lib/SimpleSAML/SessionHandlerStore.php
@@ -38,7 +38,7 @@ class SessionHandlerStore extends SessionHandlerCookie
      *
      * @param string|null $sessionId The ID of the session we should load, or null to use the default.
      *
-     * @return \SimpleSAML_Session|null The session object, or null if it doesn't exist.
+     * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist.
      */
     public function loadSession($sessionId = null)
     {
@@ -54,7 +54,7 @@ class SessionHandlerStore extends SessionHandlerCookie
 
         $session = $this->store->get('session', $sessionId);
         if ($session !== null) {
-            assert($session instanceof \SimpleSAML_Session);
+            assert($session instanceof Session);
             return $session;
         }
 
@@ -65,9 +65,9 @@ class SessionHandlerStore extends SessionHandlerCookie
     /**
      * Save a session to the data store.
      *
-     * @param \SimpleSAML_Session $session The session object we should save.
+     * @param \SimpleSAML\Session $session The session object we should save.
      */
-    public function saveSession(\SimpleSAML_Session $session)
+    public function saveSession(Session $session)
     {
         $sessionId = $session->getSessionId();
 
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index b7608ac3820ecabb8a28f14e62bae763f8326387..03bd67ba2718fc609b44879ac28c5ceb08347ff7 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -566,7 +566,7 @@ class SimpleSAML_Utilities
             'url'  => $destination,
         );
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->setData('core_postdatalink', $postId, $postData);
 
         $redirInfo = base64_encode(SimpleSAML\Utils\Crypto::aesEncrypt($session->getSessionId().':'.$postId));
diff --git a/lib/SimpleSAML/Utils/Auth.php b/lib/SimpleSAML/Utils/Auth.php
index cd2dbc29e38c484b05a7d05718b0380964e1bd4e..adf34811021c5ce4901895e2db030654d14f6a3a 100644
--- a/lib/SimpleSAML/Utils/Auth.php
+++ b/lib/SimpleSAML/Utils/Auth.php
@@ -41,7 +41,7 @@ class Auth
      */
     public static function isAdmin()
     {
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         return $session->isValid('admin') || $session->isValid('login-admin');
     }
 
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index 011fdb5f304603a3c4d1000c503c6d6d3cf22913..a6641ac6be3629e08322dcd748d0e24119b3e663 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -2,8 +2,9 @@
 namespace SimpleSAML\Utils;
 
 use SimpleSAML\Configuration;
-use SimpleSAML\Module;
 use SimpleSAML\Logger;
+use SimpleSAML\Module;
+use SimpleSAML\Session;
 
 /**
  * HTTP-related utility methods.
@@ -26,7 +27,7 @@ class HTTP
      */
     private static function getSecurePOSTRedirectURL($destination, $data)
     {
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = Session::getSessionFromRequest();
         $id = self::savePOSTData($session, $destination, $data);
 
         // get the session ID
@@ -206,7 +207,7 @@ class HTTP
     /**
      * Save the given HTTP POST data and the destination where it should be posted to a given session.
      *
-     * @param \SimpleSAML_Session $session The session where to temporarily store the data.
+     * @param \SimpleSAML\Session $session The session where to temporarily store the data.
      * @param string              $destination The destination URL where the form should be posted.
      * @param array               $data An associative array with the data to be posted to $destination.
      *
@@ -215,7 +216,7 @@ class HTTP
      * @author Andjelko Horvat
      * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
      */
-    private static function savePOSTData(\SimpleSAML_Session $session, $destination, $data)
+    private static function savePOSTData(Session $session, $destination, $data)
     {
         // generate a random ID to avoid replay attacks
         $id = Random::generateID();
@@ -290,7 +291,7 @@ class HTTP
             throw new \InvalidArgumentException('Invalid input parameters.');
         }
 
-        $session = \SimpleSAML_Session::getSessionFromRequest();
+        $session = Session::getSessionFromRequest();
         if ($session->hasSessionCookie()) {
             return;
         }
@@ -677,7 +678,7 @@ class HTTP
             // we need to post the data to HTTP
             $url = self::getSecurePOSTRedirectURL($destination, $data);
         } else { // post the data directly
-            $session = \SimpleSAML_Session::getSessionFromRequest();
+            $session = Session::getSessionFromRequest();
             $id = self::savePOSTData($session, $destination, $data);
             $url = Module::getModuleURL('core/postredirect.php', array('RedirId' => $id));
         }
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index c1b7ef3c352c96ddab79497a153e7dcb8003a9e3..57a95b99b1317adbca35303050059ef8063057f1 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -42,7 +42,7 @@ class SimpleSAML_XHTML_IdPDisco
     /**
      * The users session.
      *
-     * @var SimpleSAML_Session
+     * @var \SimpleSAML\Session
      */
     protected $session;
 
@@ -120,7 +120,7 @@ class SimpleSAML_XHTML_IdPDisco
         // initialize standard classes
         $this->config = \SimpleSAML\Configuration::getInstance();
         $this->metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-        $this->session = SimpleSAML_Session::getSessionFromRequest();
+        $this->session = \SimpleSAML\Session::getSessionFromRequest();
         $this->instance = $instance;
         $this->metadataSets = $metadataSets;
 
diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php
index c5897274378fa3b869b719a65f079cb42ed5a338..43780fe9915a306d982ba78b48f0c7ac9e1b3d56 100644
--- a/modules/core/lib/Auth/Process/ExtendIdPSession.php
+++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php
@@ -24,7 +24,7 @@ class sspmod_core_Auth_Process_ExtendIdPSession extends SimpleSAML_Auth_Processi
 		}
 
 		// Update authority expire time
-		$session = SimpleSAML_Session::getSessionFromRequest();
+		$session = \SimpleSAML\Session::getSessionFromRequest();
 		$session->setAuthorityExpire($state['Authority']);
 
 		/* Update session cookies duration */
diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php
index 82a1a4efe98f2f24011a6fc3ff99c25734092059..2eb19e35483c7149209208ee659e932f1ebe2424 100644
--- a/modules/core/www/cardinality_error.php
+++ b/modules/core/www/cardinality_error.php
@@ -10,7 +10,7 @@ if (!array_key_exists('StateId', $_REQUEST)) {
 }
 $id = $_REQUEST['StateId'];
 $state = \SimpleSAML_Auth_State::loadState($id, 'core:cardinality');
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 \SimpleSAML\Logger::stats('core:cardinality:error '.$state['Destination']['entityid'].' '.$state['saml:sp:IdP'].
     ' '.implode(',', array_keys($state['core:cardinality:errorAttributes'])));
diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php
index 20c95f3936a041b3ed9e3a92214827b5e72e154a..243221342cbb2d27a73f08722835d15a9895c137 100644
--- a/modules/core/www/frontpage_auth.php
+++ b/modules/core/www/frontpage_auth.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index 72b8c5617d555b75f0856d51e012e6470ddacb9c..b268297387caba8c11129d657a52921d4f2216e5 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index fb9ba7d6e2021f32bb391f62932791ca766c0feb..713aab5acfea48f467fa8a2417e8f58260bc0428 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php
index ec617127348987b989ce4351f5bba1dec95869fe..8ebb5e6f9bd8d59ef56733fd7966ce5c05d285bb 100644
--- a/modules/core/www/frontpage_welcome.php
+++ b/modules/core/www/frontpage_welcome.php
@@ -3,7 +3,7 @@
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists.
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/postredirect.php b/modules/core/www/postredirect.php
index 446a54e2e28f62235c1f9f83c147c2f71f9dd7c5..06d52ce4b36181c0d9be775356b14bb240138bf8 100644
--- a/modules/core/www/postredirect.php
+++ b/modules/core/www/postredirect.php
@@ -8,7 +8,7 @@
 
 if (array_key_exists('RedirId', $_REQUEST)) {
 	$postId = $_REQUEST['RedirId'];
-	$session = SimpleSAML_Session::getSessionFromRequest();
+	$session = \SimpleSAML\Session::getSessionFromRequest();
 } elseif (array_key_exists('RedirInfo', $_REQUEST)) {
 	$encData = base64_decode($_REQUEST['RedirInfo']);
 
@@ -22,7 +22,7 @@ if (array_key_exists('RedirId', $_REQUEST)) {
 		throw new SimpleSAML_Error_BadRequest('Invalid session info data.');
 	}
 
-	$session = SimpleSAML_Session::getSession($sessionId);
+	$session = \SimpleSAML\Session::getSession($sessionId);
 } else {
 	throw new SimpleSAML_Error_BadRequest('Missing redirection info parameter.');
 }
diff --git a/modules/core/www/short_sso_interval.php b/modules/core/www/short_sso_interval.php
index ec9673327e10b266ed74f050ee805cedae8eb751..ce61bdfe69d9cce58eaabb855d97c77864bde40e 100644
--- a/modules/core/www/short_sso_interval.php
+++ b/modules/core/www/short_sso_interval.php
@@ -11,7 +11,7 @@ if (!array_key_exists('StateId', $_REQUEST)) {
 }
 $id = $_REQUEST['StateId'];
 $state = SimpleSAML_Auth_State::loadState($id, 'core:short_sso_interval');
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 if (array_key_exists('continue', $_REQUEST)) {
 	// The user has pressed the continue/retry-button
diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php
index 07744c3e1efd72307c8a6317544a0ba8ab7d5fa0..d1a65b1aee69588744886429a0a5e5bb59ee74b7 100644
--- a/modules/core/www/show_metadata.php
+++ b/modules/core/www/show_metadata.php
@@ -2,7 +2,7 @@
 
 // load configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 SimpleSAML\Utils\Auth::requireAdmin();
 
diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php
index 8d207e79e436860a93dd4744fd35d9f6d717f69f..643d245027f8a02b375e5c70ff5a2a9b3761eeef 100644
--- a/modules/cron/www/croninfo.php
+++ b/modules/cron/www/croninfo.php
@@ -9,7 +9,7 @@ require_once('_include.php');
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 SimpleSAML\Utils\Auth::requireAdmin();
 
diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php
index f04c09831625bb33b811e33077debf5634382e5f..8d8283346d8766d1f2edc07d87e786d81bf4058b 100644
--- a/modules/multiauth/lib/Auth/Source/MultiAuth.php
+++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php
@@ -154,8 +154,8 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		}
 
 		/* Save the selected authentication source for the logout process. */
-		$session = SimpleSAML_Session::getSessionFromRequest();
-		$session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
+		$session = \SimpleSAML\Session::getSessionFromRequest();
+		$session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END);
 
 		try {
 			$as->authenticate($state);
@@ -180,7 +180,7 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		assert(is_array($state));
 
 		/* Get the source that was used to authenticate */
-		$session = SimpleSAML_Session::getSessionFromRequest();
+		$session = \SimpleSAML\Session::getSessionFromRequest();
 		$authId = $session->getData(self::SESSION_SOURCE, $this->authId);
 
 		$source = SimpleSAML_Auth_Source::getById($authId);
diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php
index f54d7551c5755e4cfd1e2a9598f724caf95e18ea..77d81697ba4e2f4df50a3491840798748ca14842 100644
--- a/modules/negotiate/lib/Auth/Source/Negotiate.php
+++ b/modules/negotiate/lib/Auth/Source/Negotiate.php
@@ -96,7 +96,7 @@ class sspmod_negotiate_Auth_Source_Negotiate extends SimpleSAML_Auth_Source
         }
         /* Go straight to fallback if Negotiate is disabled or if you are sent back to the IdP directly from the SP
         after having logged out. */
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $disabled = $session->getData('negotiate:disable', 'session');
 
         if ($disabled ||
@@ -353,7 +353,7 @@ EOF;
         SimpleSAML\Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"');
 
         if ($authId === null) {
-            $session = SimpleSAML_Session::getSessionFromRequest();
+            $session = \SimpleSAML\Session::getSessionFromRequest();
             $session->setData('negotiate:disable', 'session', true, 24 * 60 * 60);
             parent::logout($state);
         } else {
diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php
index bd9fbc76f8a35a207a5cb1b32db754bc155fe0a0..ba5d7834af55b33d735e644dd1ac9d2fa0de9424 100644
--- a/modules/negotiate/www/disable.php
+++ b/modules/negotiate/www/disable.php
@@ -16,7 +16,7 @@ $params = array(
 \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', 'True', $params, FALSE);
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:disable.php');
 $t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/enable.php');
diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php
index 68b8e5af8f6e4f6e788fae8b8f7732a4bb19a645..926bb31865b2df6276876d88a9f885bb5eb817c2 100644
--- a/modules/negotiate/www/enable.php
+++ b/modules/negotiate/www/enable.php
@@ -15,7 +15,7 @@ $params = array(
 \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', NULL, $params, FALSE);
 
 $globalConfig = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:enable.php');
 $t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/disable.php');
diff --git a/modules/negotiate/www/retry.php b/modules/negotiate/www/retry.php
index a39b9596bd94597c3bca7542444ee9146e77e2f3..5b76da0f0fa8b8c8552bc303eca01904772ee3c4 100644
--- a/modules/negotiate/www/retry.php
+++ b/modules/negotiate/www/retry.php
@@ -19,7 +19,7 @@ if (isset($idpmeta['auth'])) {
 	if ($source === NULL)
 		throw new SimpleSAML_Error_BadRequest('Invalid AuthId "' . $idpmeta['auth'] . '" - not found.');
 
-	$session = SimpleSAML_Session::getSessionFromRequest();
+	$session = \SimpleSAML\Session::getSessionFromRequest();
 	$session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 	SimpleSAML\Logger::debug('Negotiate(retry) - session enabled, retrying.');
 	$source->authenticate($state);
diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php
index 629f63e71886a856f203ebc63487fc151e09a47c..32cf7bb11557827df8b1788ee8cc1b4ec41afe7f 100644
--- a/modules/oauth/www/registry.edit.php
+++ b/modules/oauth/www/registry.edit.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php
index ad7c573475303239259aafadf8ef4c56c6ceb6c6..62b7e3ee8f31801796b8e3722e14ee425d439bc7 100644
--- a/modules/oauth/www/registry.php
+++ b/modules/oauth/www/registry.php
@@ -2,7 +2,7 @@
 
 // Load SimpleSAMLphp, configuration and metadata
 $config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $oauthconfig = \SimpleSAML\Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 23de5db8e17b4bf6a424fa4849bde1c669f87881..a93ed5df641f785c51627b08cfae01faefa7550f 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -440,7 +440,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
     {
         assert(is_array($state));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $data = $session->getAuthState($this->authId);
         foreach ($data as $k => $v) {
             $state[$k] = $v;
@@ -572,7 +572,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
         assert(isset($state['ReturnCallback']));
 
         // Update session state
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $authId = $state['saml:sp:AuthId'];
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
@@ -755,7 +755,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source
         assert(is_string($authId));
         assert(is_string($redirectTo));
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $session->doLogin($authId, SimpleSAML_Auth_State::getPersistentAuthData($state));
 
         \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo);
diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index d4a4004509d39e495155a118447325946422f326..18f01d8f810d37a5b261f54973ac5d93c412bd95 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -211,7 +211,7 @@ class sspmod_saml_SP_LogoutStore
             $sessionIndex = sha1($sessionIndex);
         }
 
-        $session = SimpleSAML_Session::getSessionFromRequest();
+        $session = \SimpleSAML\Session::getSessionFromRequest();
         $sessionId = $session->getSessionId();
 
         if ($store instanceof \SimpleSAML\Store\SQL) {
@@ -281,7 +281,7 @@ class sspmod_saml_SP_LogoutStore
 
             $sessionId = $sessions[$sessionIndex];
 
-            $session = SimpleSAML_Session::getSession($sessionId);
+            $session = \SimpleSAML\Session::getSession($sessionId);
             if ($session === null) {
                 SimpleSAML\Logger::info('saml.LogoutStore: Skipping logout of missing session.');
                 continue;
diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index 7e18f0e81ace7f8750dfc730a0512db570f7e539..6fd5cee3f802a3dc065b4a8ed7e61b2de3530a4e 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -49,7 +49,7 @@ if ($idp === null) {
     }
 }
 
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 $prevAuth = $session->getAuthData($sourceId, 'saml:sp:prevAuth');
 if ($prevAuth !== null && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $idp) {
     /* OK, it looks like this message has the same issuer
diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php
index efe2bf33d3b82a91824a61050a19e89e0945efc7..7dc2448ba6ed30054fada9cbd4c0a09eee3180b4 100644
--- a/modules/statistics/www/showstats.php
+++ b/modules/statistics/www/showstats.php
@@ -2,7 +2,7 @@
 
 $config = \SimpleSAML\Configuration::getInstance();
 $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php');
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 sspmod_statistics_AccessCheck::checkAccess($statconfig);
 
diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php
index 216e57cb560ed21d0d2545e9bbe2c611e1c95225..a007aa7933d084b4e5b711711060398e1cb78efe 100644
--- a/www/admin/hostnames.php
+++ b/www/admin/hostnames.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/admin/index.php b/www/admin/index.php
index 9a78941a40ea53a34b770e4b5af3f3485290cf3f..8dde15c9e8e72d692fa7ced1a5844fbea7acd527 100644
--- a/www/admin/index.php
+++ b/www/admin/index.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php
index 9b6072580068d39a51264a8ef4ae677b425805e0..9a20e0046c9d64d8592c7f5b740278ad1bab269c 100644
--- a/www/admin/metadata-converter.php
+++ b/www/admin/metadata-converter.php
@@ -1,4 +1,5 @@
 <?php
+
 require_once('../_include.php');
 
 // make sure that the user has admin access rights
diff --git a/www/admin/phpinfo.php b/www/admin/phpinfo.php
index 2b6b3d7cc5e0dfdfd6695c6d84a03581d13bc8ad..eb46c93772028d40e703798478d239a39fcfacfc 100644
--- a/www/admin/phpinfo.php
+++ b/www/admin/phpinfo.php
@@ -3,6 +3,6 @@
 require_once('../_include.php');
 
 // Make sure that the user has admin access rights
-SimpleSAML\Utils\Auth::requireAdmin();
+\SimpleSAML\Utils\Auth::requireAdmin();
 
 phpinfo();
diff --git a/www/admin/sandbox.php b/www/admin/sandbox.php
index f6bcb66ba86d9d66486c71208efb5f39a191ab5c..2f000536ba84aab5c465812650848cb089d771fc 100644
--- a/www/admin/sandbox.php
+++ b/www/admin/sandbox.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 // Load SimpleSAMLphp configuration
 $config = \SimpleSAML\Configuration::getInstance();
-$session = SimpleSAML_Session::getSessionFromRequest();
+$session = \SimpleSAML\Session::getSessionFromRequest();
 
 // Check if valid local session exists..
 //SimpleSAML\Utils\Auth::requireAdmin();
diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index c385b16a53d83c5775c14d793a2ed55318199ede..cb18a0e0c7eaa65b9bc7225c06f0717aab1ba89d 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -96,7 +96,7 @@ try {
     $memcache->set($sessionID, $data, 0, $expirationTime);
 
     // register logout handler
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $session = \SimpleSAML\Session::getSessionFromRequest();
     $session->registerLogoutHandler($sourceId, 'SimpleSAML_AuthMemCookie', 'logoutHandler');
 
     // redirect the user back to this page to signal that the login is completed
diff --git a/www/errorreport.php b/www/errorreport.php
index ae2bea150adbe84cb3543c082d5bda1f919f79a4..c03eb8d1e93c30871b2bef3d48a4d1ac0702ddbd 100644
--- a/www/errorreport.php
+++ b/www/errorreport.php
@@ -19,7 +19,7 @@ $text = htmlspecialchars((string) $_REQUEST['text']);
 
 $data = null;
 try {
-    $session = SimpleSAML_Session::getSessionFromRequest();
+    $session = \SimpleSAML\Session::getSessionFromRequest();
     $data = $session->getData('core:errorreport', $reportId);
 } catch (Exception $e) {
     SimpleSAML\Logger::error('Error loading error report data: '.var_export($e->getMessage(), true));