diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index af86ae4c07b02b69928cb10e8f5314e7cc19b3e5..f31636e779a70c7bc5acac2b2d8137216ca3eff7 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -50,6 +50,14 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
 	private $parameters;
 
 
+	/**
+	 * Name of custom include template for the error.
+	 *
+	 * @var string|NULL
+	 */
+	protected $includeTemplate = NULL;
+
+
 	/**
 	 * Constructor for this error.
 	 *
@@ -217,6 +225,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
 		$data['module'] = $this->module;
 		$data['dictTitle'] = $this->dictTitle;
 		$data['dictDescr'] = $this->dictDescr;
+		$data['includeTemplate'] = $this->includeTemplate;
 
 		/* Check if there is a valid technical contact email address. */
 		if($config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
diff --git a/lib/SimpleSAML/Error/MetadataNotFound.php b/lib/SimpleSAML/Error/MetadataNotFound.php
index fb2d483237ae2cbe8f67a1d59d4c4a061ac63d8a..940b914e3b69f5cd21f0db79e8ba1d1def28ad57 100644
--- a/lib/SimpleSAML/Error/MetadataNotFound.php
+++ b/lib/SimpleSAML/Error/MetadataNotFound.php
@@ -8,13 +8,6 @@
  */
 class SimpleSAML_Error_MetadataNotFound extends SimpleSAML_Error_Error {
 
-	/**
-	 * The entityID we were unable to locate.
-	 *
-	 * @var string
-	 */
-	private $entityId;
-
 
 	/**
 	 * Create the error
@@ -24,31 +17,11 @@ class SimpleSAML_Error_MetadataNotFound extends SimpleSAML_Error_Error {
 	public function __construct($entityId) {
 		assert('is_string($entityId)');
 
+		$this->includeTemplate = 'core:no_metadata.tpl.php';
 		parent::__construct(array(
 				'METADATANOTFOUND',
-				'ENTITYID' => htmlspecialchars(var_export($entityId, TRUE))
+				'%ENTITYID%' => htmlspecialchars(var_export($entityId, TRUE))
 		));
-
-		$this->entityId = $entityId;
-	}
-
-
-	/**
-	 * Show the error to the user.
-	 *
-	 * This function does not return.
-	 */
-	public function show() {
-
-		header('HTTP/1.0 500 Internal Server Error');
-
-		$this->logError();
-
-		$globalConfig = SimpleSAML_Configuration::getInstance();
-		$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_metadata.tpl.php');
-		$t->data['entityId'] = $this->entityId;
-		$t->show();
-		exit();
 	}
 
 }
diff --git a/lib/SimpleSAML/Error/NoState.php b/lib/SimpleSAML/Error/NoState.php
index 7233807262a27069b92c7dce8d63beee0279f980..903840dee4c78c456f5032a9c8ce3576d86978b1 100644
--- a/lib/SimpleSAML/Error/NoState.php
+++ b/lib/SimpleSAML/Error/NoState.php
@@ -14,44 +14,8 @@ class SimpleSAML_Error_NoState extends SimpleSAML_Error_Error {
 	 * Create the error
 	 */
 	public function __construct() {
+		$this->includeTemplate = 'core:no_state.tpl.php';
 		parent::__construct('NOSTATE');
 	}
 
-
-	/**
-	 * Show the error to the user.
-	 *
-	 * This function does not return.
-	 */
-	public function show() {
-
-		header('HTTP/1.0 500 Internal Server Error');
-
-		$errorData = $this->saveError();
-
-		$session = SimpleSAML_Session::getInstance();
-		$attributes = $session->getAttributes();
-		if (isset($attributes['mail'][0])) {
-			$email = $attributes['mail'][0];
-		} else {
-			$email = '';
-		}
-
-
-		$globalConfig = SimpleSAML_Configuration::getInstance();
-		$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_state.tpl.php');
-
-		/* Enable error reporting if we have a valid technical contact email. */
-		if($globalConfig->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
-			/* Enable error reporting. */
-			$baseurl = SimpleSAML_Utilities::getBaseURL();
-			$t->data['errorReportAddress'] = $baseurl . 'errorreport.php';
-			$t->data['reportId'] = $errorData['reportId'];
-			$t->data['email'] = $email;
-		}
-
-		$t->show();
-		exit();
-	}
-
 }
diff --git a/modules/core/templates/no_metadata.tpl.php b/modules/core/templates/no_metadata.tpl.php
index 09cdbbc33d1c767cc5ae38121d11d70035759f3c..d3b638b22542158ff7c6042c6433947291cb612c 100644
--- a/modules/core/templates/no_metadata.tpl.php
+++ b/modules/core/templates/no_metadata.tpl.php
@@ -1,11 +1,5 @@
 <?php
 
-$this->data['header'] = $this->t('{core:no_metadata:header}');
-$this->includeAtTemplateBase('includes/header.php');
-
-echo('<h2>' . $this->t('{core:no_metadata:header}') . '</h2>');
-echo('<p>' . $this->t('{core:no_metadata:not_found_for}') . '</p>');
-echo('<code style="margin-left: 3em;">' . htmlspecialchars($this->data['entityId']) . '</code>');
 echo('<p>' . $this->t('{core:no_metadata:config_problem}') . '</p>');
 
 echo('<ul>');
@@ -13,4 +7,3 @@ echo('<li>' . $this->t('{core:no_metadata:suggestion_user_link}') . '</li>');
 echo('<li>' . $this->t('{core:no_metadata:suggestion_developer}') . '</li>');
 echo('</ul>');
 
-$this->includeAtTemplateBase('includes/footer.php');
diff --git a/modules/core/templates/no_state.tpl.php b/modules/core/templates/no_state.tpl.php
index 8cf07f79357575b7494fdd9aee3c5fe633cd2be2..f86e346e0e8fdebe1360e384c0f941a7dee8a639 100644
--- a/modules/core/templates/no_state.tpl.php
+++ b/modules/core/templates/no_state.tpl.php
@@ -1,11 +1,5 @@
 <?php
 
-$this->data['header'] = $this->t('{core:no_state:header}');
-$this->includeAtTemplateBase('includes/header.php');
-
-echo('<h2>' . $this->t('{core:no_state:header}') . '</h2>');
-echo('<p>' . $this->t('{core:no_state:description}') . '</p>');
-
 echo('<h3>' . $this->t('{core:no_state:suggestions}') . '</h3>');
 echo('<ul>');
 echo('<li>' . $this->t('{core:no_state:suggestion_goback}') . '</li>');
@@ -19,25 +13,3 @@ echo('<li>' . $this->t('{core:no_state:cause_openbrowser}') . '</li>');
 echo('<li>' . $this->t('{core:no_state:cause_nocookie}') . '</li>');
 echo('</ul>');
 
-
-/* Add error report submit section if we have a valid technical contact. */
-if (isset($this->data['errorReportAddress'])) {
-
-	echo('<h2>' . $this->t('{core:no_state:report_header}') . '</h2>');
-
-	echo('<form action="' . htmlspecialchars($this->data['errorReportAddress']) . '" method="post">');
-
-	echo('<p>' . $this->t('{core:no_state:report_text}') . '</p>');
-	echo('<p>' . $this->t('{errors:report_email}') . '<input type="text" size="25" name="email" value="' . htmlspecialchars($this->data['email']) . '"/></p>');
-
-	echo('<p>');
-	echo('<textarea style="width: 300px; height: 100px" name="text">' . $this->t('{errors:report_explain}') . '</textarea>');
-	echo('</p>');
-	echo('<p>');
-	echo('<input type="hidden" name="reportId" value="' . $this->data['reportId'] . '" />');
-	echo('<input type="submit" name="send" value="' . $this->t('{errors:report_submit}') . '" />');
-	echo('</p>');
-	echo('</form>');
-}
-
-$this->includeAtTemplateBase('includes/footer.php');
diff --git a/templates/error.php b/templates/error.php
index b9603a4351d91b6e455e17107ef5b9c014725f06..b4358af42b6628493bc529f5e801b56fa67014a7 100644
--- a/templates/error.php
+++ b/templates/error.php
@@ -1,5 +1,5 @@
 <?php 
-	$this->data['header'] = $this->t('error_header');
+	$this->data['header'] = $this->t($this->data['dictTitle']);
 	
 	$this->data['head'] = '
 <meta name="robots" content="noindex, nofollow" />
@@ -8,11 +8,15 @@
 	$this->includeAtTemplateBase('includes/header.php'); 
 ?>
 
-
 	<h2><?php echo $this->t($this->data['dictTitle']); ?></h2>
 
 <?php
 echo htmlspecialchars($this->t($this->data['dictDescr'], $this->data['parameters']));
+
+/* Include optional information for error. */
+if (isset($this->data['includeTemplate'])) {
+	$this->includeAtTemplateBase($this->data['includeTemplate']);
+}
 ?>
 
 	<div class="trackidtext">