diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index ab9bd0258ce3616e75df383a83a72130f15bc7c1..4acb7c291d6ba8c92982c21f749b1dfbec3eb3c2 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -269,7 +269,7 @@ class Error extends Exception
             call_user_func($show_function, $config, $data);
             Assert::true(false);
         } else {
-            $t = new Template($config, 'error.php', 'errors');
+            $t = new Template($config, 'error.twig', 'errors');
             $t->data = array_merge($t->data, $data);
             $t->send();
         }
diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php
index 627fea7d018cf0e1c25b55587eb589424cf87579..7ec89343fd755e92e2c82b7bb90b4b17800ba2f4 100644
--- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php
+++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php
@@ -99,7 +99,7 @@ class IFrameLogoutHandler implements LogoutHandlerInterface
 
         $config = Configuration::getInstance();
 
-        $t = new Template($config, 'IFrameLogoutHandler.tpl.php');
+        $t = new Template($config, 'IFrameLogoutHandler.twig');
         $t->data['assocId'] = var_export($assocId, true);
         $t->data['spId'] = sha1($assocId);
         if (!is_null($error)) {
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index a0ab8ecd200096accef500fc9d7276aea11fb925..cdf1ba72285dba2114c3fce2a3ef8640d2a9b19e 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -1250,7 +1250,7 @@ class HTTP
             self::redirect(self::getSecurePOSTRedirectURL($destination, $data));
         }
 
-        $p = new Template($config, 'post.php');
+        $p = new Template($config, 'post.twig');
         $p->data['destination'] = $destination;
         $p->data['post'] = $data;
         $p->send();
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index 7b71ec0538385a284eb3f5a065b805eabc40bfc8..6fa300240da245a83ff7a8383e1ef92a5f1bdaf4 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -582,10 +582,10 @@ class IdPDisco
          */
         switch ($this->config->getString('idpdisco.layout', 'links')) {
             case 'dropdown':
-                $templateFile = 'selectidp-dropdown.php';
+                $templateFile = 'selectidp-dropdown.twig';
                 break;
             case 'links':
-                $templateFile = 'selectidp-links.php';
+                $templateFile = 'selectidp-links.twig';
                 break;
             default:
                 throw new \Exception('Invalid value for the \'idpdisco.layout\' option.');
diff --git a/modules/core/lib/Controller/Exception.php b/modules/core/lib/Controller/Exception.php
index 905f8c1164a5ff47ffc932bf27bec284ba540236..8bf7ce3000b331ce385072accc7b32efaaae92b6 100644
--- a/modules/core/lib/Controller/Exception.php
+++ b/modules/core/lib/Controller/Exception.php
@@ -73,15 +73,6 @@ class Exception
             ' ' . implode(',', array_keys($state['core:cardinality:errorAttributes']))
         );
 
-        $t = new Template($this->config, 'core:cardinality_error.tpl.php');
-        $t->data['cardinalityErrorAttributes'] = $state['core:cardinality:errorAttributes'];
-        if (isset($state['Source']['auth'])) {
-            $t->data['LogoutURL'] = Module::getModuleURL(
-                'core/authenticate.php',
-                ['as' => $state['Source']['auth']]
-            ) . "&logout";
-        }
-
         $t = new Template($this->config, 'core:cardinality_error.twig');
         $t->data['cardinalityErrorAttributes'] = $state['core:cardinality:errorAttributes'];
         if (isset($state['Source']['auth'])) {
diff --git a/modules/cron/lib/Controller/Cron.php b/modules/cron/lib/Controller/Cron.php
index e3d1a01767b694d98a9a15c01b119414be6581f8..57af87a169b98c0be704e17783aadea17db25d91 100644
--- a/modules/cron/lib/Controller/Cron.php
+++ b/modules/cron/lib/Controller/Cron.php
@@ -87,7 +87,7 @@ class Cron
             ];
         }
 
-        $t = new Template($this->config, 'cron:croninfo.tpl.php', 'cron:cron');
+        $t = new Template($this->config, 'cron:croninfo.twig', 'cron:cron');
         $t->data['urls'] = $urls;
         return $t;
     }
@@ -138,7 +138,7 @@ class Cron
         }
 
         if ($output === 'xhtml') {
-            $t = new Template($this->config, 'cron:croninfo-result.tpl.php', 'cron:cron');
+            $t = new Template($this->config, 'cron:croninfo-result.twig', 'cron:cron');
             $t->data['tag'] = $croninfo['tag'];
             $t->data['time'] = $time;
             $t->data['url'] = $url;