diff --git a/attributealter/edupersontargetid.php b/attributealter/edupersontargetid.php
new file mode 100644
index 0000000000000000000000000000000000000000..b1d4e2ccb07debc95a24ab30b6805e587194f605
--- /dev/null
+++ b/attributealter/edupersontargetid.php
@@ -0,0 +1,10 @@
+<?php
+function attributealter_edupersontargetedid(&$attributes, $spEntityId = null, $idpEntityId = null) {
+	assert('$spEntityId !== NULL');
+	assert('$idpEntityId !== NULL');
+
+	$userid = SimpleSAML_Utilities::generateUserIdentifier($idpEntityId, $spEntityId, $attributes);
+
+	$attributes['eduPersonTargetedID'] = array($userid);
+}
+?>
\ No newline at end of file
diff --git a/attributealter/alterfunctions.php b/attributealter/groups.php
similarity index 64%
rename from attributealter/alterfunctions.php
rename to attributealter/groups.php
index 3e3ec46b299d3f98e53b06e5e801b1166a98b089..00d6490080a7f19802cf04c327049faa1ff69efd 100644
--- a/attributealter/alterfunctions.php
+++ b/attributealter/groups.php
@@ -1,8 +1,4 @@
 <?php
-
-
-
-
 function encodeIllegalChars($input) {
 	return preg_replace("/[^a-zA-Z0-9_@=.]/", "_", $input);
 }
@@ -72,36 +68,4 @@ function attributealter_groups(&$attributes, $spentityid = null, $idpentityid =
 	$attributes['groups'] = $groups;
 
 }
-
-
-
-function attributealter_test(&$attributes, $spentityid = null, $idpentityid = null) {
-	$attributes['injected'] = array('newvalue');
-}
-
-function attributealter_realm(&$attributes, $spentityid = null, $idpentityid = null) {
-
-	$attributename = 'eduPersonPrincipalName';
-#	$attributename = 'edupersonprincipalname';
-	if (array_key_exists($attributename, $attributes)) {
-		$eduppn = $attributes[$attributename][0];
-		$splitted = explode('@', $eduppn);
-		if (count($splitted) > 1) {
-			$attributes['realm'] = array($splitted[1]);
-		} else {
-			SimpleSAML_Logger::debug('attributealter_realm: Wrong format on ' . $attributename . ' (not including @)');
-		}
-	} else {
-		SimpleSAML_Logger::debug('attributealter_realm: Could not find ' . $attributename);
-	}
-
-}
-
-function attributealter_edupersontargetedid(&$attributes, $spEntityId = null, $idpEntityId = null) {
-	assert('$spEntityId !== NULL');
-	assert('$idpEntityId !== NULL');
-
-	$userid = SimpleSAML_Utilities::generateUserIdentifier($idpEntityId, $spEntityId, $attributes);
-
-	$attributes['eduPersonTargetedID'] = array($userid);
-}
+?>
\ No newline at end of file
diff --git a/attributealter/realm.php b/attributealter/realm.php
new file mode 100644
index 0000000000000000000000000000000000000000..a279d50b1c273c77518a504bc7e12e618a44f6e7
--- /dev/null
+++ b/attributealter/realm.php
@@ -0,0 +1,19 @@
+<?php
+function attributealter_realm(&$attributes, $spentityid = null, $idpentityid = null) {
+
+	$attributename = 'eduPersonPrincipalName';
+#	$attributename = 'edupersonprincipalname';
+	if (array_key_exists($attributename, $attributes)) {
+		$eduppn = $attributes[$attributename][0];
+		$splitted = explode('@', $eduppn);
+		if (count($splitted) > 1) {
+			$attributes['realm'] = array($splitted[1]);
+		} else {
+			SimpleSAML_Logger::debug('attributealter_realm: Wrong format on ' . $attributename . ' (not including @)');
+		}
+	} else {
+		SimpleSAML_Logger::debug('attributealter_realm: Could not find ' . $attributename);
+	}
+
+}
+?>
\ No newline at end of file
diff --git a/attributealter/test.php b/attributealter/test.php
new file mode 100644
index 0000000000000000000000000000000000000000..6f3c0f8bb49ab204ddedae795aaebdfe784a9ef1
--- /dev/null
+++ b/attributealter/test.php
@@ -0,0 +1,5 @@
+<?php
+function attributealter_test(&$attributes, $spentityid = null, $idpentityid = null) {
+	$attributes['injected'] = array('newvalue');
+}
+?>
\ No newline at end of file
diff --git a/lib/SimpleSAML/XML/AttributeFilter.php b/lib/SimpleSAML/XML/AttributeFilter.php
index bc359ad8dd830f8c2c4e40d3017cb5e51b600dc5..39d19d32a80655690551e8769b3de70a4497f8a1 100644
--- a/lib/SimpleSAML/XML/AttributeFilter.php
+++ b/lib/SimpleSAML/XML/AttributeFilter.php
@@ -93,8 +93,8 @@ class SimpleSAML_XML_AttributeFilter {
 	 */
 	public function alter($rule, $spentityid = null, $idpentityid = null) {
 		
-		$alterfile = $this->configuration->getBaseDir() . 'attributealter/alterfunctions.php';
-		if (!file_exists($alterfile)) throw new Exception('Could not find attributemap file: ' . $alterfile);
+		$alterfile = $this->configuration->getBaseDir() . 'attributealter/' . $rule . '.php';
+		if (!file_exists($alterfile)) throw new Exception('Could not find attributealter file: ' . $alterfile);
 		
 		include_once($alterfile);
 		
@@ -103,7 +103,7 @@ class SimpleSAML_XML_AttributeFilter {
 		if (function_exists($function)) {
 			$function($this->attributes, $spentityid, $idpentityid);
 		} else {
-			throw new Exception('Could not find attribute alter fucntion: ' . $function);
+			throw new Exception('Could not find attribute alter fucntion: ' . $function . ' in file ' .$alterfile);
 		}
 		
 	}