diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index fb36bf83d541dfac321b94ce2857ff7cc36f0fbd..e6b2f13f77d227cb0dea37b0273d261a05623105 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -190,8 +190,7 @@ class SimpleSAML_Auth_Simple {
 			$returnTo = SimpleSAML_Utilities::selfURL();
 		}
 
-		$login = SimpleSAML_Module::getModuleURL('core/as_login.php');
-		$login = SimpleSAML_Utilities::addURLparameter($login, array(
+		$login = SimpleSAML_Module::getModuleURL('core/as_login.php', array(
 			'AuthId' => $this->authSource,
 			'ReturnTo' => $returnTo,
 		));
@@ -216,8 +215,7 @@ class SimpleSAML_Auth_Simple {
 			$returnTo = SimpleSAML_Utilities::selfURL();
 		}
 
-		$logout = SimpleSAML_Module::getModuleURL('core/as_logout.php');
-		$logout = SimpleSAML_Utilities::addURLparameter($logout, array(
+		$logout = SimpleSAML_Module::getModuleURL('core/as_logout.php', array(
 			'AuthId' => $this->authSource,
 			'ReturnTo' => $returnTo,
 		));
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index cf7d9921c1d18efe779c5c3ed75a5c18036f7001..deaac70142ce49f371940422749af048312e833a 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -1771,7 +1771,7 @@ class SimpleSAML_Utilities {
 			$returnTo = SimpleSAML_Utilities::selfURL();
 		}
 
-		return SimpleSAML_Module::getModuleURL('core/login-admin.php?ReturnTo=' . urlencode($returnTo));
+		return SimpleSAML_Module::getModuleURL('core/login-admin.php', array('ReturnTo' => $returnTo));
 	}
 
 
@@ -1845,10 +1845,7 @@ class SimpleSAML_Utilities {
 		$session = SimpleSAML_Session::getInstance();
 		$session->setData('core_postdatalink', $id, $postData);
 
-		return SimpleSAML_Utilities::addURLParameter(
-			SimpleSAML_Module::getModuleURL('core/postredirect.php'),
-			array('RedirId' => $id)
-			);
+		return SimpleSAML_Module::getModuleURL('core/postredirect.php', array('RedirId' => $id));
 	}
 
 
diff --git a/modules/consent/www/noconsent.php b/modules/consent/www/noconsent.php
index 60678d3fec636c6c701268cc61498279e68f5595..de677f8068d1563e76c8b479564d21c12d6c0eda 100644
--- a/modules/consent/www/noconsent.php
+++ b/modules/consent/www/noconsent.php
@@ -14,8 +14,7 @@ if (!array_key_exists('StateId', $_REQUEST)) {
 $id = $_REQUEST['StateId'];
 $state = SimpleSAML_Auth_State::loadState($id, 'consent:request');
 
-$resumeFrom = SimpleSAML_Module::getModuleURL('consent/getconsent.php');
-$resumeFrom = SimpleSAML_Utilities::addURLParameter($resumeFrom, array('StateId' => $id));
+$resumeFrom = SimpleSAML_Module::getModuleURL('consent/getconsent.php', array('StateId' => $id));
 
 $aboutService = NULL;
 if(isset($state['Destination']['url.about']) ){
diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php
index 6bc4039eee9274066c90dfcfc26efb66e9af155c..2d5d134bf42c37c059270473176a8909b163c763 100644
--- a/modules/core/templates/frontpage_federation.tpl.php
+++ b/modules/core/templates/frontpage_federation.tpl.php
@@ -78,7 +78,7 @@ foreach($this->data['metaentries']['remote'] AS $setkey => $set) {
 	foreach($set AS $entry) {
 		echo '<li>';
 		echo ('<a href="' . 
-			SimpleSAML_Module::getModuleURL('core/show_metadata.php?entityid=' . urlencode($entry['entityid']) . '&amp;set=' . urlencode($setkey) ) . 
+			htmlspecialchars(SimpleSAML_Module::getModuleURL('core/show_metadata.php', array('entityid' => $entry['entityid'], 'set' => $setkey ))) .
 			'">');
 		if (array_key_exists('name', $entry)) {
 			echo $this->getTranslation(SimpleSAML_Utilities::arrayize($entry['name'], 'en'));
diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php
index 1c1458eb163f3fd262ec4e2b0ce2ee2f2986d4b9..0e55715631f38ccb94194db77cbb801d1369dd42 100644
--- a/modules/cron/www/croninfo.php
+++ b/modules/cron/www/croninfo.php
@@ -28,7 +28,7 @@ $def = array(
 $urls = array();
 foreach ($tags AS $tag) {
 	$urls[] = array(
-		'href' => SimpleSAML_Module::getModuleURL('cron/cron.php?key=' . $key . '&amp;tag=' . $tag),
+		'href' => SimpleSAML_Module::getModuleURL('cron/cron.php', array('key' => $key, 'tag' => $tag)),
 		'tag' => $tag,
 		'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']),
 	);
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index ab3c73b5c379b1ea250f280496f56798befb7d55..5aa7505695588a11eb0ad8934630b3863c466268 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -260,8 +260,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 			$discoURL = SimpleSAML_Module::getModuleURL('saml/disco.php');
 		}
 
-		$returnTo = SimpleSAML_Module::getModuleURL('saml/sp/discoresp.php');
-		$returnTo = SimpleSAML_Utilities::addURLparameter($returnTo, array('AuthID' => $id));
+		$returnTo = SimpleSAML_Module::getModuleURL('saml/sp/discoresp.php', array('AuthID' => $id));
 
 		SimpleSAML_Utilities::redirect($discoURL, array(
 			'entityID' => $this->entityId,
diff --git a/modules/saml2/lib/Auth/Source/SP.php b/modules/saml2/lib/Auth/Source/SP.php
index c5320df1d06c8660d814969e411adb790f9d16a2..503f8183b85f1ff0a9c19432d90b6cd85534f149 100644
--- a/modules/saml2/lib/Auth/Source/SP.php
+++ b/modules/saml2/lib/Auth/Source/SP.php
@@ -156,8 +156,7 @@ class sspmod_saml2_Auth_Source_SP extends SimpleSAML_Auth_Source {
 			$discoURL = SimpleSAML_Module::getModuleURL('saml2/disco.php');
 		}
 
-		$returnTo = SimpleSAML_Module::getModuleURL('saml2/sp/discoresp.php');
-		$returnTo = SimpleSAML_Utilities::addURLparameter($returnTo, array('AuthID' => $id));
+		$returnTo = SimpleSAML_Module::getModuleURL('saml2/sp/discoresp.php', array('AuthID' => $id));
 
 		SimpleSAML_Utilities::redirect($discoURL, array(
 			'entityID' => $this->entityId,