diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php
index 85d6975033c43f45bc55f27ffa47509dab7cec90..529c9f7a94c3f35003003b4c52b703f6a4b01f70 100644
--- a/lib/SimpleSAML/Configuration.php
+++ b/lib/SimpleSAML/Configuration.php
@@ -1020,7 +1020,7 @@ class SimpleSAML_Configuration {
 
 		$endpoints = $this->getEndpoints($endpointType);
 
-		$defaultEndpoint = SimpleSAML_Utilities::getDefaultEndpoint($endpoints, $bindings);
+		$defaultEndpoint = \SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($endpoints, $bindings);
 		if ($defaultEndpoint !== NULL) {
 			return $defaultEndpoint;
 		}
diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index d43d05f2435f8e31361741d68a447ddaa205fa4e..703d28c2899d784dcdf1fd75c97a4c5d4bdcb3c1 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -474,7 +474,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		foreach ($metadata->getArray('contacts', array()) as $contact) {
 			if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) {
-				$this->addContact($contact['contactType'], SimpleSAML_Utils_Config_Metadata::getContact($contact));
+				$this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact));
 			}
 		}
 
@@ -520,7 +520,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 
 		foreach ($metadata->getArray('contacts', array()) as $contact) {
 			if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) {
-				$this->addContact($contact['contactType'], SimpleSAML_Utils_Config_Metadata::getContact($contact));
+				$this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact));
 			}
 		}
 
@@ -633,7 +633,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 		assert('in_array($type, array("technical", "support", "administrative", "billing", "other"), TRUE)');
 
 		// TODO: remove this check as soon as getContact() is called always before calling this function.
-		$details = SimpleSAML_Utils_Config_Metadata::getContact($details);
+		$details = \SimpleSAML\Utils\Config\Metadata::getContact($details);
 
 		$e = new SAML2_XML_md_ContactPerson();
 		$e->contactType = $type;
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 70251d1296179330b2976b8587386b6b9f87ebf0..46a649f77d52241fe0e380503a85b6987809b4ae 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -827,53 +827,10 @@ class SimpleSAML_Utilities {
 
 
 	/**
-	 * Find the default endpoint in an endpoint array.
-	 *
-	 * @param array $endpoints  Array with endpoints.
-	 * @param array $bindings  Array with acceptable bindings. Can be NULL if any binding is allowed.
-	 * @return  array|NULL  The default endpoint, or NULL if no acceptable endpoints are used.
+	 * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint() instead.
 	 */
 	public static function getDefaultEndpoint(array $endpoints, array $bindings = NULL) {
-
-		$firstNotFalse = NULL;
-		$firstAllowed = NULL;
-
-		/* Look through the endpoint list for acceptable endpoints. */
-		foreach ($endpoints as $i => $ep) {
-			if ($bindings !== NULL && !in_array($ep['Binding'], $bindings, TRUE)) {
-				/* Unsupported binding. Skip it. */
-				continue;
-			}
-
-			if (array_key_exists('isDefault', $ep)) {
-				if ($ep['isDefault'] === TRUE) {
-					/* This is the first endpoitn with isDefault set to TRUE. */
-					return $ep;
-				}
-				/* isDefault is set to FALSE, but the endpoint is still useable as a last resort. */
-				if ($firstAllowed === NULL) {
-					/* This is the first endpoint that we can use. */
-					$firstAllowed = $ep;
-				}
-			} else {
-				if ($firstNotFalse === NULL) {
-					/* This is the first endpoint without isDefault set. */
-					$firstNotFalse = $ep;
-				}
-			}
-		}
-
-		if ($firstNotFalse !== NULL) {
-			/* We have an endpoint without isDefault set to FALSE. */
-			return $firstNotFalse;
-		}
-
-		/*
-		 * $firstAllowed either contains the first endpoint we can use, or it
-		 * contains NULL if we cannot use any of the endpoints. Either way we
-		 * return the value of it.
-		 */
-		return $firstAllowed;
+		return \SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($endpoints, $bindings);
 	}
 
 
diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php
index fa28c2c88d4e16e9250d651fff9094b5c5f7b23c..72c0d0d947ae8e7c0745c13e3aea4a2cf73278ce 100644
--- a/lib/SimpleSAML/Utils/Config/Metadata.php
+++ b/lib/SimpleSAML/Utils/Config/Metadata.php
@@ -1,5 +1,5 @@
 <?php
-
+namespace SimpleSAML\Utils\Config;
 
 /**
  * Class with utilities to fetch different configuration objects from metadata configuration arrays.
@@ -7,7 +7,7 @@
  * @package SimpleSAMLphp
  * @author Jaime Pérez Crespo, UNINETT AS <jaime.perez@uninett.no>
  */
-class SimpleSAML_Utils_Config_Metadata
+class Metadata
 {
 
     /**
@@ -72,7 +72,7 @@ class SimpleSAML_Utils_Config_Metadata
      * @return array An array holding valid contact configuration options. If a key 'name' was part of the input array,
      * it will try to decompose the name into its parts, and place the parts into givenName and surName, if those are
      * missing.
-     * @throws InvalidArgumentException if the contact does not conform to valid configuration rules for contacts.
+     * @throws \InvalidArgumentException if the contact does not conform to valid configuration rules for contacts.
      */
     public static function getContact($contact)
     {
@@ -86,7 +86,7 @@ class SimpleSAML_Utils_Config_Metadata
                 },
                 self::$VALID_CONTACT_TYPES
             ));
-            throw new InvalidArgumentException('"contactType" is mandatory and must be one of '.$types.".");
+            throw new \InvalidArgumentException('"contactType" is mandatory and must be one of '.$types.".");
         }
 
         // try to fill in givenName and surName from name
@@ -114,7 +114,7 @@ class SimpleSAML_Utils_Config_Metadata
                 empty($contact['givenName']) || !is_string($contact['givenName'])
             )
         ) {
-            throw new InvalidArgumentException('"givenName" must be a string and cannot be empty.');
+            throw new \InvalidArgumentException('"givenName" must be a string and cannot be empty.');
         }
 
         // check surName
@@ -122,7 +122,7 @@ class SimpleSAML_Utils_Config_Metadata
                 empty($contact['surName']) || !is_string($contact['surName'])
             )
         ) {
-            throw new InvalidArgumentException('"surName" must be a string and cannot be empty.');
+            throw new \InvalidArgumentException('"surName" must be a string and cannot be empty.');
         }
 
         // check company
@@ -130,7 +130,7 @@ class SimpleSAML_Utils_Config_Metadata
                 empty($contact['company']) || !is_string($contact['company'])
             )
         ) {
-            throw new InvalidArgumentException('"company" must be a string and cannot be empty.');
+            throw new \InvalidArgumentException('"company" must be a string and cannot be empty.');
         }
 
         // check emailAddress
@@ -138,12 +138,12 @@ class SimpleSAML_Utils_Config_Metadata
             if (empty($contact['emailAddress']) ||
                 !(is_string($contact['emailAddress']) || is_array($contact['emailAddress']))
             ) {
-                throw new InvalidArgumentException('"emailAddress" must be a string or an array and cannot be empty.');
+                throw new \InvalidArgumentException('"emailAddress" must be a string or an array and cannot be empty.');
             }
             if (is_array($contact['emailAddress'])) {
                 foreach ($contact['emailAddress'] as $address) {
                     if (!is_string($address) || empty($address)) {
-                        throw new InvalidArgumentException('Email addresses must be a string and cannot be empty.');
+                        throw new \InvalidArgumentException('Email addresses must be a string and cannot be empty.');
                     }
                 }
             }
@@ -154,12 +154,12 @@ class SimpleSAML_Utils_Config_Metadata
             if (empty($contact['telephoneNumber']) ||
                 !(is_string($contact['telephoneNumber']) || is_array($contact['telephoneNumber']))
             ) {
-                throw new InvalidArgumentException('"telephoneNumber" must be a string or an array and cannot be empty.');
+                throw new \InvalidArgumentException('"telephoneNumber" must be a string or an array and cannot be empty.');
             }
             if (is_array($contact['telephoneNumber'])) {
                 foreach ($contact['telephoneNumber'] as $address) {
                     if (!is_string($address) || empty($address)) {
-                        throw new InvalidArgumentException('Telephone numbers must be a string and cannot be empty.');
+                        throw new \InvalidArgumentException('Telephone numbers must be a string and cannot be empty.');
                     }
                 }
             }
diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php
index 3b95150254ba731fec4741afd0f95b491c890438..a77a0a027dbf316fe9e58230ebbe157786d1759f 100644
--- a/modules/adfs/www/idp/metadata.php
+++ b/modules/adfs/www/idp/metadata.php
@@ -112,7 +112,7 @@ try {
 	$metaBuilder->addOrganizationInfo($metaArray);
 	$technicalContactEmail = $config->getString('technicalcontact_email', NULL);
 	if ($technicalContactEmail && $technicalContactEmail !== 'na@example.org') {
-		$metaBuilder->addContact('technical', SimpleSAML_Utils_Config_Metadata::getContact(array(
+		$metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array(
 			'emailAddress' => $technicalContactEmail,
 			'name' => $config->getString('technicalcontact_name', NULL),
 			'contactType' => 'technical',
diff --git a/modules/metaedit/www/edit.php b/modules/metaedit/www/edit.php
index ddbf207813ec8d18a55a6e342c7037a772aa7ec4..a2851b16ea6acf302e0ef8c08a6ee55c95c07fba 100644
--- a/modules/metaedit/www/edit.php
+++ b/modules/metaedit/www/edit.php
@@ -37,8 +37,8 @@ if (array_key_exists('entityid', $_REQUEST)) {
 	$metadata =  $entity->getMetadata20SP();
 
 	/* Trim metadata endpoint arrays. */
-	$metadata['AssertionConsumerService'] = array(SimpleSAML_Utilities::getDefaultEndpoint($metadata['AssertionConsumerService'], array(SAML2_Const::BINDING_HTTP_POST)));
-	$metadata['SingleLogoutService'] = array(SimpleSAML_Utilities::getDefaultEndpoint($metadata['SingleLogoutService'], array(SAML2_Const::BINDING_HTTP_REDIRECT)));
+	$metadata['AssertionConsumerService'] = array(\SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($metadata['AssertionConsumerService'], array(SAML2_Const::BINDING_HTTP_POST)));
+	$metadata['SingleLogoutService'] = array(\SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($metadata['SingleLogoutService'], array(SAML2_Const::BINDING_HTTP_REDIRECT)));
 
 } else {
 	$metadata = array(
diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index f41e8ac84f10e9d0826cd359fe97490605b5721c..1dde24284bbd5aa6f8f5b5a7c7f75a6f635f5c7f 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -164,7 +164,7 @@ if ($orgName !== NULL) {
 if ($spconfig->hasValue('contacts')) {
 	$contacts = $spconfig->getArray('contacts');
 	foreach ($contacts as $contact) {
-		$metaArray20['contacts'][] = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+		$metaArray20['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
 	}
 }
 
@@ -174,7 +174,7 @@ if ($email && $email !== 'na@example.org') {
 	$techcontact['emailAddress'] = $email;
 	$techcontact['name'] = $config->getString('technicalcontact_name', NULL);
 	$techcontact['contactType'] = 'technical';
-	$metaArray20['contacts'][] = SimpleSAML_Utils_Config_Metadata::getContact($techcontact);
+	$metaArray20['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($techcontact);
 }
 
 // add certificate
diff --git a/tests/Metadata/MetadataTest.php b/tests/Metadata/MetadataTest.php
index 81e039180fc3793e83d08d433f2fa3cb161caa38..26ca926729bfbf14291c1a7e792133eba272f7e2 100644
--- a/tests/Metadata/MetadataTest.php
+++ b/tests/Metadata/MetadataTest.php
@@ -17,7 +17,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'name' => 'John Doe'
         );
         try {
-            $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+            $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         } catch (InvalidArgumentException $e) {
             $this->assertStringStartsWith('"contactType" is mandatory and must be one of ', $e->getMessage());
         }
@@ -27,17 +27,17 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'contactType' => 'invalid'
         );
         try {
-            $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+            $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         } catch (InvalidArgumentException $e) {
             $this->assertStringStartsWith('"contactType" is mandatory and must be one of ', $e->getMessage());
         }
 
         // test all valid contact types
-        foreach (SimpleSAML_Utils_Config_Metadata::$VALID_CONTACT_TYPES as $type) {
+        foreach (\SimpleSAML\Utils\Config\Metadata::$VALID_CONTACT_TYPES as $type) {
             $contact = array(
                 'contactType' => $type
             );
-            $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+            $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             $this->assertArrayHasKey('contactType', $parsed);
             $this->assertArrayNotHasKey('givenName', $parsed);
             $this->assertArrayNotHasKey('surName', $parsed);
@@ -48,7 +48,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'contactType' => 'technical',
             'name'        => 'John Doe'
         );
-        $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+        $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         $this->assertArrayNotHasKey('name', $parsed);
         $this->assertArrayHasKey('givenName', $parsed);
         $this->assertArrayHasKey('surName', $parsed);
@@ -60,7 +60,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'contactType' => 'technical',
             'name'        => 'Doe, John'
         );
-        $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+        $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         $this->assertArrayHasKey('givenName', $parsed);
         $this->assertArrayHasKey('surName', $parsed);
         $this->assertEquals('John', $parsed['givenName']);
@@ -71,7 +71,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'contactType' => 'technical',
             'name'        => 'John Fitzgerald Doe Smith'
         );
-        $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+        $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         $this->assertArrayNotHasKey('name', $parsed);
         $this->assertArrayHasKey('givenName', $parsed);
         $this->assertArrayNotHasKey('surName', $parsed);
@@ -82,7 +82,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
             'contactType' => 'technical',
             'name'        => 'Doe Smith, John Fitzgerald'
         );
-        $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+        $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         $this->assertArrayNotHasKey('name', $parsed);
         $this->assertArrayHasKey('givenName', $parsed);
         $this->assertArrayHasKey('surName', $parsed);
@@ -97,7 +97,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['givenName'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals('"givenName" must be a string and cannot be empty.', $e->getMessage());
             }
@@ -111,7 +111,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['surName'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals('"surName" must be a string and cannot be empty.', $e->getMessage());
             }
@@ -125,7 +125,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['company'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals('"company" must be a string and cannot be empty.', $e->getMessage());
             }
@@ -139,7 +139,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['emailAddress'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals(
                     '"emailAddress" must be a string or an array and cannot be empty.',
@@ -151,7 +151,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['emailAddress'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals(
                     'Email addresses must be a string and cannot be empty.',
@@ -168,7 +168,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['telephoneNumber'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals(
                     '"telephoneNumber" must be a string or an array and cannot be empty.',
@@ -180,7 +180,7 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
         foreach ($invalid_types as $type) {
             $contact['telephoneNumber'] = $type;
             try {
-                SimpleSAML_Utils_Config_Metadata::getContact($contact);
+                \SimpleSAML\Utils\Config\Metadata::getContact($contact);
             } catch (InvalidArgumentException $e) {
                 $this->assertEquals('Telephone numbers must be a string and cannot be empty.', $e->getMessage());
             }
@@ -188,12 +188,12 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
 
         // test completeness
         $contact = array();
-        foreach (SimpleSAML_Utils_Config_Metadata::$VALID_CONTACT_OPTIONS as $option) {
+        foreach (\SimpleSAML\Utils\Config\Metadata::$VALID_CONTACT_OPTIONS as $option) {
             $contact[$option] = 'string';
         }
         $contact['contactType'] = 'technical';
         $contact['name'] = 'to_be_removed';
-        $parsed = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+        $parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
         foreach (array_keys($parsed) as $key) {
             $this->assertEquals($parsed[$key], $contact[$key]);
         }
diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php
index d78aefbb7def5ef7fbd1b5b5f626c54c60673312..631865a9f78bc54f92be95f62b6ac48e0f3f4b59 100644
--- a/www/saml2/idp/metadata.php
+++ b/www/saml2/idp/metadata.php
@@ -161,7 +161,7 @@ try {
 	if ($idpmeta->hasValue('contacts')) {
 		$contacts = $idpmeta->getArray('contacts');
 		foreach ($contacts as $contact) {
-			$metaArray['contacts'][] = SimpleSAML_Utils_Config_Metadata::getContact($contact);
+			$metaArray['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
 		}
 	}
 
@@ -170,7 +170,7 @@ try {
 		$techcontact['emailAddress'] = $technicalContactEmail;
 		$techcontact['name'] = $config->getString('technicalcontact_name', NULL);
 		$techcontact['contactType'] = 'technical';
-		$metaArray['contacts'][] = SimpleSAML_Utils_Config_Metadata::getContact($techcontact);
+		$metaArray['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($techcontact);
 	}
 
 	$metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid);
diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php
index 73234215d22a8eae46b1be445378711d96f5ef73..f47c59148d998ed5eb68e47b009316a7d3748278 100644
--- a/www/shib13/idp/metadata.php
+++ b/www/shib13/idp/metadata.php
@@ -69,7 +69,7 @@ try {
 	$metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid);
 	$metaBuilder->addMetadataIdP11($metaArray);
 	$metaBuilder->addOrganizationInfo($metaArray);
-	$metaBuilder->addContact('technical', SimpleSAML_Utils_Config_Metadata::getContact(array(
+	$metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array(
 		'emailAddress' => $config->getString('technicalcontact_email', NULL),
 		'name' => $config->getString('technicalcontact_name', NULL),
 		'contactType' => 'technical',