diff --git a/docs/simplesamlphp-errorhandling.md b/docs/simplesamlphp-errorhandling.md
index 7fbc4f16b454772bd0fb9ad324e0a73002c283f9..2a5c08a0d962875eb7bf4652cc7a8a3c493c4c88 100644
--- a/docs/simplesamlphp-errorhandling.md
+++ b/docs/simplesamlphp-errorhandling.md
@@ -206,8 +206,8 @@ The code for handling this becomes something like:
     $procChain = [...];
 
     $state = array(
-        'ReturnURL' => \SimpleSAML\Utilities::selfURLNoQuery(),
-        \SimpleSAML\Auth\State::EXCEPTION_HANDLER_URL => \SimpleSAML\Utilities::selfURLNoQuery(),
+        'ReturnURL' => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(),
+        \SimpleSAML\Auth\State::EXCEPTION_HANDLER_URL => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(),
         [...],
     )
 
diff --git a/docs/simplesamlphp-sp-migration.md b/docs/simplesamlphp-sp-migration.md
index 1b9e6d3f66aa531235a06a549b73e592531eb4f4..f3251610eb343ef6ca23efeac97e9c547778031d 100644
--- a/docs/simplesamlphp-sp-migration.md
+++ b/docs/simplesamlphp-sp-migration.md
@@ -168,10 +168,10 @@ Blocks of code like the following:
 
     /* Check if valid local session exists.. */
     if (!isset($session) || !$session->isValid('saml2') ) {
-      SimpleSAML_Utilities::redirect(
+      \SimpleSAML\Utilities::redirect(
         '/' . $config->getBaseURL() .
         'saml2/sp/initSSO.php',
-        array('RelayState' => SimpleSAML_Utilities::selfURL())
+        array('RelayState' => \SimpleSAML\Utilities::selfURL())
         );
     }
 
@@ -195,10 +195,10 @@ you should now call:
 
 Redirecting to the initSLO-script:
 
-    SimpleSAML_Utilities::redirect(
+    \SimpleSAML\Utilities::redirect(
         '/' . $config->getBaseURL() .
         'saml2/sp/initSLO.php',
-        array('RelayState' => SimpleSAML_Utilities::selfURL())
+        array('RelayState' => \SimpleSAML\Utilities::selfURL())
         );
 
 should be replaced with a call to `logout()`:
@@ -210,7 +210,7 @@ If you want to return to a specific URL after logging out, you should include th
     $as->logout('https://example.org/');
 
 Please make sure the URL is trusted. If you obtain the URL from the user input, make sure it is trusted before
-calling $as->logout(), by using the SimpleSAML_Utilities::checkURLAllowed() method.
+calling $as->logout(), by using the \SimpleSAML\Utilities::checkURLAllowed() method.
 
 
 #### Login link
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 2189449ffc04bc11d182e14a45f4d96a69f999fc..15739a034ca4e330b57fb07e019114ba6bf94857 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace SimpleSAML;
+
 /**
  * Misc static functions that is used several places.in example parsing and id generation.
  *
@@ -9,7 +11,7 @@
  * @deprecated This entire class will be removed in SimpleSAMLphp 2.0.
  */
 
-class SimpleSAML_Utilities
+class Utilities
 {
     /**
      * @deprecated This property will be removed in SSP 2.0. Please use SimpleSAML\Logger::isErrorMasked() instead.
@@ -148,7 +150,7 @@ class SimpleSAML_Utilities
      */
     public static function generateID()
     {
-        return SimpleSAML\Utils\Random::generateID();
+        return \SimpleSAML\Utils\Random::generateID();
     }
 
 
@@ -158,7 +160,7 @@ class SimpleSAML_Utilities
      */
     public static function generateTimestamp($instant = null)
     {
-        return SimpleSAML\Utils\Time::generateTimestamp($instant);
+        return \SimpleSAML\Utils\Time::generateTimestamp($instant);
     }
 
 
@@ -167,7 +169,7 @@ class SimpleSAML_Utilities
      */
     public static function parseDuration($duration, $timestamp = null)
     {
-        return SimpleSAML\Utils\Time::parseDuration($duration, $timestamp);
+        return \SimpleSAML\Utils\Time::parseDuration($duration, $timestamp);
     }
 
 
@@ -185,7 +187,7 @@ class SimpleSAML_Utilities
      */
     public static function ipCIDRcheck($cidr, $ip = null)
     {
-        return SimpleSAML\Utils\Net::ipCIDRcheck($cidr, $ip);
+        return \SimpleSAML\Utils\Net::ipCIDRcheck($cidr, $ip);
     }
 
 
@@ -212,7 +214,7 @@ class SimpleSAML_Utilities
         }
 
         if (strlen($url) > 2048) {
-            SimpleSAML\Logger::warning('Redirecting to a URL longer than 2048 bytes.');
+            \SimpleSAML\Logger::warning('Redirecting to a URL longer than 2048 bytes.');
         }
 
         // Set the location header
@@ -291,7 +293,7 @@ class SimpleSAML_Utilities
      */
     public static function transposeArray($in)
     {
-        return SimpleSAML\Utils\Arrays::transpose($in);
+        return \SimpleSAML\Utils\Arrays::transpose($in);
     }
 
 
@@ -301,7 +303,7 @@ class SimpleSAML_Utilities
      */
     public static function isDOMElementOfType(DOMNode $element, $name, $nsURI)
     {
-        return SimpleSAML\Utils\XML::isDOMNodeOfType($element, $name, $nsURI);
+        return \SimpleSAML\Utils\XML::isDOMNodeOfType($element, $name, $nsURI);
     }
 
 
@@ -310,7 +312,7 @@ class SimpleSAML_Utilities
      */
     public static function getDOMChildren(DOMElement $element, $localName, $namespaceURI)
     {
-        return SimpleSAML\Utils\XML::getDOMChildren($element, $localName, $namespaceURI);
+        return \SimpleSAML\Utils\XML::getDOMChildren($element, $localName, $namespaceURI);
     }
 
 
@@ -319,7 +321,7 @@ class SimpleSAML_Utilities
      */
     public static function getDOMText($element)
     {
-        return SimpleSAML\Utils\XML::getDOMText($element);
+        return \SimpleSAML\Utils\XML::getDOMText($element);
     }
 
 
@@ -418,7 +420,7 @@ class SimpleSAML_Utilities
      */
     public static function parseAttributes($attributes)
     {
-        return SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes);
+        return \SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes);
     }
 
 
@@ -427,7 +429,7 @@ class SimpleSAML_Utilities
      */
     public static function getSecretSalt()
     {
-        return SimpleSAML\Utils\Config::getSecretSalt();
+        return \SimpleSAML\Utils\Config::getSecretSalt();
     }
 
 
@@ -464,7 +466,7 @@ class SimpleSAML_Utilities
      */
     public static function loadPublicKey(\SimpleSAML\Configuration $metadata, $required = false, $prefix = '')
     {
-        return SimpleSAML\Utils\Crypto::loadPublicKey($metadata, $required, $prefix);
+        return \SimpleSAML\Utils\Crypto::loadPublicKey($metadata, $required, $prefix);
     }
 
 
@@ -473,7 +475,7 @@ class SimpleSAML_Utilities
      */
     public static function loadPrivateKey(\SimpleSAML\Configuration $metadata, $required = false, $prefix = '')
     {
-        return SimpleSAML\Utils\Crypto::loadPrivateKey($metadata, $required, $prefix);
+        return \SimpleSAML\Utils\Crypto::loadPrivateKey($metadata, $required, $prefix);
     }
 
 
@@ -482,7 +484,7 @@ class SimpleSAML_Utilities
      */
     public static function formatDOMElement(DOMElement $root, $indentBase = '')
     {
-        SimpleSAML\Utils\XML::formatDOMElement($root, $indentBase);
+        \SimpleSAML\Utils\XML::formatDOMElement($root, $indentBase);
     }
 
 
@@ -491,7 +493,7 @@ class SimpleSAML_Utilities
      */
     public static function formatXMLString($xml, $indentBase = '')
     {
-        return SimpleSAML\Utils\XML::formatXMLString($xml, $indentBase);
+        return \SimpleSAML\Utils\XML::formatXMLString($xml, $indentBase);
     }
 
 
@@ -500,7 +502,7 @@ class SimpleSAML_Utilities
      */
     public static function arrayize($data, $index = 0)
     {
-        return SimpleSAML\Utils\Arrays::arrayize($data, $index);
+        return \SimpleSAML\Utils\Arrays::arrayize($data, $index);
     }
 
 
@@ -509,7 +511,7 @@ class SimpleSAML_Utilities
      */
     public static function isAdmin()
     {
-        return SimpleSAML\Utils\Auth::isAdmin();
+        return \SimpleSAML\Utils\Auth::isAdmin();
     }
 
 
@@ -518,7 +520,7 @@ class SimpleSAML_Utilities
      */
     public static function getAdminLoginURL($returnTo = null)
     {
-        return SimpleSAML\Utils\Auth::getAdminLoginURL($returnTo);
+        return \SimpleSAML\Utils\Auth::getAdminLoginURL($returnTo);
     }
 
 
@@ -559,7 +561,7 @@ class SimpleSAML_Utilities
         assert(is_string($destination));
         assert(is_array($post));
 
-        $postId = SimpleSAML\Utils\Random::generateID();
+        $postId = \SimpleSAML\Utils\Random::generateID();
         $postData = array(
             'post' => $post,
             'url'  => $destination,
@@ -570,7 +572,7 @@ class SimpleSAML_Utilities
 
         $redirInfo = base64_encode(SimpleSAML\Utils\Crypto::aesEncrypt($session->getSessionId().':'.$postId));
 
-        $url = SimpleSAML\Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $redirInfo));
+        $url = \SimpleSAML\Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $redirInfo));
         $url = preg_replace("#^https:#", "http:", $url);
 
         return $url;
@@ -609,7 +611,7 @@ class SimpleSAML_Utilities
      */
     public static function getTempDir()
     {
-        return SimpleSAML\Utils\System::getTempDir();
+        return \SimpleSAML\Utils\System::getTempDir();
     }
 
 
@@ -618,7 +620,7 @@ class SimpleSAML_Utilities
      */
     public static function maskErrors($mask)
     {
-        SimpleSAML\Logger::maskErrors($mask);
+        \SimpleSAML\Logger::maskErrors($mask);
     }
 
 
@@ -627,7 +629,7 @@ class SimpleSAML_Utilities
      */
     public static function popErrorMask()
     {
-        SimpleSAML\Logger::popErrorMask();
+        \SimpleSAML\Logger::popErrorMask();
     }
 
 
@@ -674,7 +676,7 @@ class SimpleSAML_Utilities
      */
     public static function aesEncrypt($clear)
     {
-        return SimpleSAML\Utils\Crypto::aesEncrypt($clear);
+        return \SimpleSAML\Utils\Crypto::aesEncrypt($clear);
     }
 
 
@@ -683,7 +685,7 @@ class SimpleSAML_Utilities
      */
     public static function aesDecrypt($encData)
     {
-        return SimpleSAML\Utils\Crypto::aesDecrypt($encData);
+        return \SimpleSAML\Utils\Crypto::aesDecrypt($encData);
     }
 
 
@@ -692,7 +694,7 @@ class SimpleSAML_Utilities
      */
     public static function isWindowsOS()
     {
-        return SimpleSAML\Utils\System::getOS() === SimpleSAML\Utils\System::WINDOWS;
+        return \SimpleSAML\Utils\System::getOS() === SimpleSAML\Utils\System::WINDOWS;
     }
 
 
diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php
index 0aeb8bae921edf3f388d21130a4797581f230985..70d856cd3b246e0b25f2372a8a81c054fea133ea 100644
--- a/lib/SimpleSAML/XML/Signer.php
+++ b/lib/SimpleSAML/XML/Signer.php
@@ -52,8 +52,8 @@ class Signer
      *  - privatekey       The file with the private key, relative to the cert-directory.
      *  - privatekey_pass  The passphrase for the private key.
      *  - certificate      The file with the certificate, relative to the cert-directory.
-     *  - privatekey_array The private key, as an array returned from SimpleSAML_Utilities::loadPrivateKey.
-     *  - publickey_array  The public key, as an array returned from SimpleSAML_Utilities::loadPublicKey.
+     *  - privatekey_array The private key, as an array returned from \SimpleSAML\Utils\Crypto::loadPrivateKey.
+     *  - publickey_array  The public key, as an array returned from \SimpleSAML\Utils\Crypto::loadPublicKey.
      *  - id               The name of the ID attribute.
      *
      * @param array $options  Associative array with options for the constructor. Defaults to an empty array.
@@ -93,7 +93,7 @@ class Signer
      * Set the private key from an array.
      *
      * This function loads the private key from an array matching what is returned
-     * by SimpleSAML_Utilities::loadPrivateKey(...).
+     * by \SimpleSAML\Utils\Crypto::loadPrivateKey(...).
      *
      * @param array $privatekey  The private key.
      */
@@ -155,7 +155,7 @@ class Signer
      * Set the public key / certificate we should include in the signature.
      *
      * This function loads the public key from an array matching what is returned
-     * by SimpleSAML_Utilities::loadPublicKey(...).
+     * by \SimpleSAML\Utils\Crypto::loadPublicKey(...).
      *
      * @param array $publickey The public key.
      * @throws \Exception
diff --git a/lib/SimpleSAML/XML/Validator.php b/lib/SimpleSAML/XML/Validator.php
index 6d8a4f32a6acfb65e1e5be7f0da24f909b42af2e..00eaf11cd84f30989bb35dc6460067b5e4b1be9c 100644
--- a/lib/SimpleSAML/XML/Validator.php
+++ b/lib/SimpleSAML/XML/Validator.php
@@ -36,7 +36,7 @@ class Validator
      * take the following values:
      * - NULL/FALSE: No validation will be performed. This is the default.
      * - A string: Assumed to be a PEM-encoded certificate / public key.
-     * - An array: Assumed to be an array returned by SimpleSAML_Utilities::loadPublicKey.
+     * - An array: Assumed to be an array returned by \SimpleSAML\Utils\Crypto::loadPublicKey.
      *
      * @param \DOMNode $xmlNode The XML node which contains the Signature element.
      * @param string|array $idAttribute The ID attribute which is used in node references. If