diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5c285787445e3b70a64617302453c1aef9966c1a..9d3a7427b39daaf56fadbece16472306d016945c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
 [Added]
 - Added file phpcs.xml
 
+[Changed]
+- Changed code style to PSR-2
+
 ## [v2.2.0]
 [Added]
 - Added support for pass selected IdP from SP in AuthnContextClassRef attribute.
diff --git a/config-templates/config-warning.php b/config-templates/config-warning.php
index 7791cc4e14548abdfec66c802ffb05165904a4c5..2a3cd627f40cec294e2638ba95a140ee0d7d455e 100644
--- a/config-templates/config-warning.php
+++ b/config-templates/config-warning.php
@@ -5,23 +5,24 @@
  */
 $config = array(
 
-	/**
-	 * When true, the config file is switched on.
-	 */
-	'isOn' => true,
+    /**
+     * When true, the config file is switched on.
+     */
+    'isOn' => true,
 
-	/**
-	 * When true, user is able to continue.
-	 */
-	'userCanContinue' => true,
+    /**
+     * When true, user is able to continue.
+     */
+    'userCanContinue' => true,
 
-	/**
-	 * Title of the warning. It is possible to use HTML.
-	 */
-	'title' => '<b> Title of the warning </b>',
+    /**
+     * Title of the warning. It is possible to use HTML.
+     */
+    'title' => '<b> Title of the warning </b>',
 
-	/**
-	 * Text of the warning. It is possible to use HTML.
-	 */
-	'text' => '<p> Due to maintenance it won\'t be possible to access our service from <b>1.1.2018 2:00</b> to <b>1.1.2018 4:00</b> </p>',
+    /**
+     * Text of the warning. It is possible to use HTML.
+     */
+    'text' => '<p> Due to maintenance it won\'t be possible to access our service from ' .
+                '<b>1.1.2018 2:00</b> to <b>1.1.2018 4:00</b> </p>',
 );
diff --git a/themes/bbmri/consent/consentform.php b/themes/bbmri/consent/consentform.php
index d5d9ef8734800086c53a233c2a3884d4c6f81eaa..348eaf30239f2b4632b5569d34139859a8cefc39 100644
--- a/themes/bbmri/consent/consentform.php
+++ b/themes/bbmri/consent/consentform.php
@@ -1,4 +1,8 @@
 <?php
+
+use SimpleSAML\Module;
+use SimpleSAML\Utils\Arrays;
+
 /**
  * Template form for giving consent.
  *
@@ -56,14 +60,12 @@ $attributes = $this->data['attributes'];
 
 $this->data['header'] = $this->t('{consent:consent:consent_header}');
 
-$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('consent/style.css')  . '" />';
-$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('bbmri/res/css/consent.css')  . '" />';
+$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' .
+    Module::getModuleUrl('consent/assets/css/consent.css') . '" />';
+$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
+    Module::getModuleUrl('bbmri/res/css/consent.css') . '" />';
 
 $this->includeAtTemplateBase('includes/header.php');
-?>
-
-
-<?php
 
 /*
 echo $this->t(
@@ -71,13 +73,14 @@ echo $this->t(
     array( 'SPNAME' => $dstName, 'IDPNAME' => $srcName)
 );
 */
+
 if (array_key_exists('descr_purpose', $this->data['dstMetadata'])) {
     echo '</p><p>' . $this->t(
         '{consent:consent:consent_purpose}',
         array(
             'SPNAME' => $dstName,
             'SPDESC' => $this->getTranslation(
-                SimpleSAML\Utils\Arrays::arrayize(
+                Arrays::arrayize(
                     $this->data['dstMetadata']['descr_purpose'],
                     'en'
                 )
@@ -85,21 +88,17 @@ if (array_key_exists('descr_purpose', $this->data['dstMetadata'])) {
         )
     );
 }
-?>
 
-<?php
 if ($this->data['sppp'] !== false) {
     echo "<p>" . htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}')) . " ";
     echo "<a target='_blank' href='" . htmlspecialchars($this->data['sppp']) . "'>" . $dstName . "</a>";
     echo "</p>";
 }
 
-
-
 echo '<h3 id="attributeheader">' .
     $this->t(
         '{consent:consent:consent_attributes_header}',
-        array( 'SPNAME' => $dstName, 'IDPNAME' => $srcName)
+        array('SPNAME' => $dstName, 'IDPNAME' => $srcName)
     ) .
     '</h3>';
 
@@ -110,53 +109,48 @@ echo present_attributes($this, $attributes, '');
     <div class="row">
         <div class="col-xs-6">
 
-
             <form action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>">
-				<?php
-				if ($this->data['usestorage']) {
-					$checked = ($this->data['checked'] ? 'checked="checked"' : '');
-					echo '<div class="checkbox">
+                <?php
+                if ($this->data['usestorage']) {
+                    $checked = ($this->data['checked'] ? 'checked="checked"' : '');
+                    echo '<div class="checkbox">
     	        <label>
       		    <input type="checkbox" name="saveconsent" value="1" /> ' . $this->t('{perun:consent:remember}') . '
 	            </label>    
                 </div>';
-				}
-				?>
+                }
+                ?>
 
-				<?php
-				// Embed hidden fields...
-				foreach ($this->data['yesData'] as $name => $value) {
-					echo '<input type="hidden" name="' . htmlspecialchars($name) .
-						'" value="' . htmlspecialchars($value) . '" />';
-				}
-				?>
+                <?php
+                // Embed hidden fields...
+                foreach ($this->data['yesData'] as $name => $value) {
+                    echo '<input type="hidden" name="' . htmlspecialchars($name) .
+                        '" value="' . htmlspecialchars($value) . '" />';
+                }
+                ?>
 
                 <button type="submit" name="yes" class="btn btn-lg btn-success btn-block" id="yesbutton">
-					<?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?>
+                    <?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?>
                 </button>
 
-
             </form>
 
-
         </div>
         <div class="col-xs-6">
 
-
             <form action="<?php echo htmlspecialchars($this->data['noTarget']); ?>">
 
-				<?php
-				foreach ($this->data['noData'] as $name => $value) {
-					echo('<input type="hidden" name="' . htmlspecialchars($name) .
-						'" value="' . htmlspecialchars($value) . '" />');
-				}
-				?>
+                <?php
+                foreach ($this->data['noData'] as $name => $value) {
+                    echo('<input type="hidden" name="' . htmlspecialchars($name) .
+                        '" value="' . htmlspecialchars($value) . '" />');
+                }
+                ?>
                 <button type="submit" class="btn btn-lg btn-default btn-block  btn-no" name="no" id="nobutton">
-					<?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?>
+                    <?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?>
                 </button>
             </form>
 
-
         </div>
     </div>
 <?php
diff --git a/themes/bbmri/consent/noconsent.php b/themes/bbmri/consent/noconsent.php
index 14fb88029513655f4b0aa00586b14da4d41c356e..a139c0b3dce83b71b4f414e095a86f98a881e985 100644
--- a/themes/bbmri/consent/noconsent.php
+++ b/themes/bbmri/consent/noconsent.php
@@ -1,5 +1,7 @@
 <?php
 
+use SimpleSAML\Module;
+
 if (array_key_exists('name', $this->data['dstMetadata'])) {
     $dstName = $this->data['dstMetadata']['name'];
 } elseif (array_key_exists('OrganizationDisplayName', $this->data['dstMetadata'])) {
@@ -7,20 +9,23 @@ if (array_key_exists('name', $this->data['dstMetadata'])) {
 } else {
     $dstName = $this->data['dstMetadata']['entityid'];
 }
+
 if (is_array($dstName)) {
     $dstName = $this->t($dstName);
 }
+
 $dstName = htmlspecialchars($dstName);
 
+$this->data['header'] = $this->t('{consent:consent:noconsent_title}');
 
-$this->data['header'] = $this->t('{consent:consent:noconsent_title}');;
+$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css"' .
+    'href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />';
 
-$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />';
-$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('bbmri/res/css/consent.css')  . '" />';
+$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
+    Module::getModuleUrl('bbmri/res/css/consent.css') . '" />';
 
 $this->includeAtTemplateBase('includes/header.php');
 
-
 echo '<p>' . $this->t('{consent:consent:noconsent_text}', array('SPNAME' => $dstName)) . '</p>';
 
 if ($this->data['resumeFrom']) {
@@ -32,7 +37,7 @@ if ($this->data['resumeFrom']) {
 
 if ($this->data['aboutService']) {
     echo('<p><a href="' . htmlspecialchars($this->data['aboutService']) . '">');
-    echo('<i class="glyphicon glyphicon-info-sign"></i> ');    
+    echo('<i class="glyphicon glyphicon-info-sign"></i> ');
     echo($this->t('{consent:consent:noconsent_goto_about}'));
     echo('</a></p>');
 }
@@ -42,5 +47,4 @@ echo('<i class="glyphicon glyphicon-ban-circle"></i> ');
 echo($this->t('{consent:consent:abort}', array('SPNAME' => $dstName)));
 echo('</a></p>');
 
-
 $this->includeAtTemplateBase('includes/footer.php');
diff --git a/themes/bbmri/core/loginuserpass.php b/themes/bbmri/core/loginuserpass.php
index 7b98e7cb92a031f1447e2c2bb1d93cb358a00e23..b961f36ad7b45a75defc56a22cb3039cdf9e720c 100644
--- a/themes/bbmri/core/loginuserpass.php
+++ b/themes/bbmri/core/loginuserpass.php
@@ -2,165 +2,168 @@
 $this->data['header'] = $this->t('{login:user_pass_header}');
 
 if (strlen($this->data['username']) > 0) {
-	$this->data['autofocus'] = 'password';
+    $this->data['autofocus'] = 'password';
 } else {
-	$this->data['autofocus'] = 'username';
+    $this->data['autofocus'] = 'username';
 }
 $this->includeAtTemplateBase('includes/header.php');
 
-?>
-
-<?php
 if ($this->data['errorcode'] !== null) {
-	?>
-	<div class="alert alert-danger" >
-		<span class="glyphicon glyphicon-exclamation-sign" style="float:left; font-size: 38px; margin-right: 10px;"></span>
-
-		<strong>
-			<?php
-			echo htmlspecialchars($this->t(
-				'{errors:title_'.$this->data['errorcode'].'}',
-				$this->data['errorparams']
-			));
-			?>
-		</strong>
-
-		<?php
-		echo htmlspecialchars($this->t(
-			'{errors:descr_'.$this->data['errorcode'].'}',
-			$this->data['errorparams']
-		));
-		?>
-	</div>
-	<?php
+    ?>
+    <div class="alert alert-danger">
+        <span class="glyphicon glyphicon-exclamation-sign"
+              style="float:left; font-size: 38px; margin-right: 10px;"></span>
+
+        <strong>
+            <?php
+            echo htmlspecialchars($this->t(
+                '{errors:title_' . $this->data['errorcode'] . '}',
+                $this->data['errorparams']
+            ));
+            ?>
+        </strong>
+
+        <?php
+        echo htmlspecialchars($this->t(
+            '{errors:descr_' . $this->data['errorcode'] . '}',
+            $this->data['errorparams']
+        ));
+        ?>
+    </div>
+    <?php
 }
 
 ?>
 
-	<p><?php echo $this->t('{login:user_pass_text}'); ?></p>
-
-	<br>
-
-	<form action="?" method="post" name="f" class="form-horizontal">
-
-		<div class="form-group">
-			<label for="username" class="col-sm-2 control-label"><?php echo $this->t('{login:username}'); ?></label>
-			<div class="col-sm-10">
-				<input id="username" <?php echo ($this->data['forceUsername']) ? 'disabled="disabled"' : ''; ?>
-					   type="text" name="username" class="form-control"
-						<?php if (!$this->data['forceUsername']) {
-						echo 'tabindex="1"';
-						} ?> value="<?php echo htmlspecialchars($this->data['username']); ?>"/>
-			</div>
-		</div>
-
-		<div class="form-group">
-			<label for="password" class="col-sm-2 control-label"><?php echo $this->t('{login:password}'); ?></label>
-			<div class="col-sm-10">
-				<input id="password" type="password" tabindex="2" name="password" class="form-control"/>
-			</div>
-		</div>
-
-		<?php
-		if ($this->data['rememberUsernameEnabled'] && !$this->data['forceUsername']) {
-			// display the "remember my username" checkbox
-			?>
-			<div class="form-group">
-				<div class="col-sm-offset-2 col-sm-10">
-					<div class="checkbox">
-						<label>
-							<input type="checkbox" id="remember_username" tabindex="4"
-								<?php echo ($this->data['rememberUsernameChecked']) ? 'checked="checked"' : ''; ?>
-								   name="remember_username" value="Yes"/>
-							<?php echo $this->t('{login:remember_username}'); ?>
-						</label>
-					</div>
-				</div>
-			</div>
-			<?php
-		}
-		?>
-
-		<?php
-		if ($this->data['rememberMeEnabled']) {
-			// display the remember me checkbox (keep me logged in)
-			?>
-			<div class="form-group">
-				<div class="col-sm-offset-2 col-sm-10">
-					<div class="checkbox">
-						<label>
-							<input type="checkbox" id="remember_me" tabindex="5"
-								<?php echo ($this->data['rememberMeChecked']) ? 'checked="checked"' : ''; ?>
-								   name="remember_me" value="Yes"/>
-							<?php echo $this->t('{login:remember_me}'); ?>
-						</label>
-					</div>
-				</div>
-			</div>
-			<?php
-		}
-		?>
-
-
-		<?php
-		if (array_key_exists('organizations', $this->data)) {
-			?>
-			<div class="form-group">
-				<label for="organization" class="col-sm-2 control-label"><?php echo $this->t('{login:organization}'); ?></label>
-				<div class="col-sm-10">
-					<select name="organization" tabindex="3" class="form-control">
-						<?php
-						if (array_key_exists('selectedOrg', $this->data)) {
-							$selectedOrg = $this->data['selectedOrg'];
-						} else {
-							$selectedOrg = null;
-						}
-
-						foreach ($this->data['organizations'] as $orgId => $orgDesc) {
-							if (is_array($orgDesc)) {
-								$orgDesc = $this->t($orgDesc);
-							}
-
-							if ($orgId === $selectedOrg) {
-								$selected = 'selected="selected" ';
-							} else {
-								$selected = '';
-							}
-
-							echo '<option '.$selected.'value="'.htmlspecialchars($orgId).'">'.htmlspecialchars($orgDesc).'</option>';
-						}
-						?>
-					</select>
-				</div>
-			</div>
-			<?php
-		}
-		?>
-
-		<div class="form-group">
-			<div class="col-sm-offset-2 col-sm-10">
-				<button class="btn btn-success"
-						onclick="this.value='<?php echo $this->t('{login:processing}'); ?>';
-							this.disabled=true; this.form.submit(); return true;" tabindex="6">
-					<?php echo $this->t('{login:login_button}'); ?>
-				</button>
-			</div>
-		</div>
-
-		<?php
-		foreach ($this->data['stateparams'] as $name => $value) {
-			echo('<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />');
-		}
-		?>
-	</form>
+    <p><?php echo $this->t('{login:user_pass_text}'); ?></p>
+
+    <br>
+
+    <form action="?" method="post" name="f" class="form-horizontal">
+
+        <div class="form-group">
+            <label for="username" class="col-sm-2 control-label"><?php echo $this->t('{login:username}'); ?></label>
+            <div class="col-sm-10">
+                <input id="username" <?php echo ($this->data['forceUsername']) ? 'disabled="disabled"' : ''; ?>
+                       type="text" name="username" class="form-control"
+                    <?php
+                    if (!$this->data['forceUsername']) {
+                        echo 'tabindex="1"';
+                    }
+                    ?> value="<?php echo htmlspecialchars($this->data['username']); ?>"/>
+            </div>
+        </div>
+
+        <div class="form-group">
+            <label for="password" class="col-sm-2 control-label"><?php echo $this->t('{login:password}'); ?></label>
+            <div class="col-sm-10">
+                <input id="password" type="password" tabindex="2" name="password" class="form-control"/>
+            </div>
+        </div>
+
+        <?php
+        if ($this->data['rememberUsernameEnabled'] && !$this->data['forceUsername']) {
+            // display the "remember my username" checkbox
+            ?>
+            <div class="form-group">
+                <div class="col-sm-offset-2 col-sm-10">
+                    <div class="checkbox">
+                        <label>
+                            <input type="checkbox" id="remember_username" tabindex="4"
+                                <?php echo ($this->data['rememberUsernameChecked']) ? 'checked="checked"' : ''; ?>
+                                   name="remember_username" value="Yes"/>
+                            <?php echo $this->t('{login:remember_username}'); ?>
+                        </label>
+                    </div>
+                </div>
+            </div>
+            <?php
+        }
+        ?>
+
+        <?php
+        if ($this->data['rememberMeEnabled']) {
+            // display the remember me checkbox (keep me logged in)
+            ?>
+            <div class="form-group">
+                <div class="col-sm-offset-2 col-sm-10">
+                    <div class="checkbox">
+                        <label>
+                            <input type="checkbox" id="remember_me" tabindex="5"
+                                <?php echo ($this->data['rememberMeChecked']) ? 'checked="checked"' : ''; ?>
+                                   name="remember_me" value="Yes"/>
+                            <?php echo $this->t('{login:remember_me}'); ?>
+                        </label>
+                    </div>
+                </div>
+            </div>
+            <?php
+        }
+        ?>
+
+        <?php
+        if (array_key_exists('organizations', $this->data)) {
+            ?>
+            <div class="form-group">
+                <label for="organization"
+                       class="col-sm-2 control-label"><?php echo $this->t('{login:organization}'); ?></label>
+                <div class="col-sm-10">
+                    <select name="organization" tabindex="3" class="form-control">
+                        <?php
+                        if (array_key_exists('selectedOrg', $this->data)) {
+                            $selectedOrg = $this->data['selectedOrg'];
+                        } else {
+                            $selectedOrg = null;
+                        }
+
+                        foreach ($this->data['organizations'] as $orgId => $orgDesc) {
+                            if (is_array($orgDesc)) {
+                                $orgDesc = $this->t($orgDesc);
+                            }
+
+                            if ($orgId === $selectedOrg) {
+                                $selected = 'selected="selected" ';
+                            } else {
+                                $selected = '';
+                            }
+
+                            echo '<option ' . $selected . 'value="' . htmlspecialchars($orgId) . '">' .
+                                htmlspecialchars($orgDesc) . '</option>';
+                        }
+                        ?>
+                    </select>
+                </div>
+            </div>
+            <?php
+        }
+        ?>
+
+        <div class="form-group">
+            <div class="col-sm-offset-2 col-sm-10">
+                <button class="btn btn-success"
+                        onclick="this.value='<?php echo $this->t('{login:processing}'); ?>';
+                                this.disabled=true; this.form.submit(); return true;" tabindex="6">
+                    <?php echo $this->t('{login:login_button}'); ?>
+                </button>
+            </div>
+        </div>
+
+        <?php
+        foreach ($this->data['stateparams'] as $name => $value) {
+            echo('<input type="hidden" name="' . htmlspecialchars($name) . '" value="' .
+                htmlspecialchars($value) . '" />');
+        }
+        ?>
+    </form>
 
 <?php
 if (!empty($this->data['links'])) {
-	echo '<ul class="links" style="margin-top: 2em">';
-	foreach ($this->data['links'] as $l) {
-		echo '<li><a href="'.htmlspecialchars($l['href']).'">'.htmlspecialchars($this->t($l['text'])).'</a></li>';
-	}
-	echo '</ul>';
+    echo '<ul class="links" style="margin-top: 2em">';
+    foreach ($this->data['links'] as $l) {
+        echo '<li><a href="' . htmlspecialchars($l['href']) . '">' .
+            htmlspecialchars($this->t($l['text'])) . '</a></li>';
+    }
+    echo '</ul>';
 }
 
 $this->includeAtTemplateBase('includes/footer.php');
diff --git a/themes/bbmri/default/error.php b/themes/bbmri/default/error.php
index 5535b62e4243c93fb39c624f01a7423fc9127f77..e47fc8072c045157044b9b0dc4bbe5e19cb30137 100644
--- a/themes/bbmri/default/error.php
+++ b/themes/bbmri/default/error.php
@@ -1,89 +1,107 @@
 <?php
-$this->data['header'] =  '<i class="glyphicon glyphicon-exclamation-sign text-danger"></i> '. $this->t($this->data['dictTitle']);
+
+use SimpleSAML\Module;
+
+$this->data['header'] = '<i class="glyphicon glyphicon-exclamation-sign text-danger"></i> ' .
+    $this->t($this->data['dictTitle']);
 
 $this->data['head'] = <<<EOF
 <meta name="robots" content="noindex, nofollow" />
 <meta name="googlebot" content="noarchive, nofollow" />
 EOF;
 
-$this->data['head'] .= '<script src="' . SimpleSAML\Module::getModuleUrl('bbmri/res/js/jquery.js')  . '" ></script>';
-$this->data['head'] .= '<script src="' . SimpleSAML\Module::getModuleUrl('bbmri/res/bootstrap/js/bootstrap.min.js')  . '" ></script>';
+$this->data['head'] .= '<script src="' . Module::getModuleUrl('bbmri/res/js/jquery.js') . '" ></script>';
+$this->data['head'] .= '<script src="' . Module::getModuleUrl('bbmri/res/bootstrap/js/bootstrap.min.js')
+    . '" ></script>';
 
 $this->includeAtTemplateBase('includes/header.php');
+
 ?>
-<p>
-<?php
-echo htmlspecialchars($this->t($this->data['dictDescr'], $this->data['parameters']));
-?>
- <a href="#moreInfo" data-toggle="collapse"><?php echo $this->t('{bbmri:bbmri:more}'); ?><span class="caret"></span></a>
 
-</p>
+    <p>
+        <?php
+        echo htmlspecialchars($this->t($this->data['dictDescr'], $this->data['parameters']));
+        ?>
+        <a href="#moreInfo" data-toggle="collapse"><?php echo $this->t('{bbmri:bbmri:more}'); ?><span
+                    class="caret"></span></a>
+    </p>
 
 <?php
+
 // include optional information for error
 if (isset($this->data['includeTemplate'])) {
     $this->includeAtTemplateBase($this->data['includeTemplate']);
 }
+
 ?>
-<div id="moreInfo" class="collapse">
-	<p id="trackid" class="input-left"><?php echo $this->t('{bbmri:bbmri:error_number}'); ?><?php echo $this->data['error']['trackId']; ?></p>
-<?php
-// print out exception only if the exception is available
-if ($this->data['showerrors']) {
-?>
-    	<p style="margin: 1px"><?php echo htmlspecialchars($this->data['error']['exceptionMsg']); ?></p>
-        <pre style="padding: 1em; font-family: monospace;"><?php
-            echo htmlspecialchars($this->data['error']['exceptionTrace']); 
-	?></pre>
-<?php
-}
-?>
-</div>
+    <div id="moreInfo" class="collapse">
+        <p id="trackid"
+           class="input-left"><?php echo $this->t('{bbmri:bbmri:error_number}'); ?>
+            <?php echo $this->data['error']['trackId']; ?>
+        </p>
+        <?php
+        // print out exception only if the exception is available
+        if ($this->data['showerrors']) {
+            ?>
+            <p style="margin: 1px"><?php echo htmlspecialchars($this->data['error']['exceptionMsg']); ?></p>
+            <pre style="padding: 1em; font-family: monospace;"><?php
+                echo htmlspecialchars($this->data['error']['exceptionTrace']);
+                ?></pre>
+            <?php
+        }
+        ?>
+    </div>
 <?php
 /* Add error report submit section if we have a valid technical contact. 'errorreportaddress' will only be set if
  * the technical contact email address has been set.
  */
 if (isset($this->data['errorReportAddress'])) {
-?>
-<br>
-<div class="panel panel-default">
-  <div class="panel-heading">
-    <h3 class="panel-title"><?php echo $this->t('report_header'); ?></h3>
-  </div>
-  <div class="panel-body">
-  
-    <form action="<?php echo htmlspecialchars($this->data['errorReportAddress']); ?>" method="post" class="form-horizontal">
-
-	<div class="form-group">
-		<label class="col-sm-2 control-label" for="reportId"><?php echo $this->t('{bbmri:bbmri:error_id}'); ?></label>
-		<div class="col-sm-10">
-			<input name="reportId" type="text" class="form-control" id="reportId" value="<?php echo $this->data['error']['reportId']; ?>" readonly>
-		</div>
-	</div>
-
-	<div class="form-group">
-		<label class="col-sm-2 control-label" for="email"><?php echo $this->t('report_email'); ?></label>
-		<div class="col-sm-10">
-			<input name="email" type="email" class="form-control" id="email" placeholder="Email" required>
-			<span  class="help-block"><?php echo $this->t('{bbmri:bbmri:error_report_email_message}');?></span>
-		</div>
-	</div>
-
-	<div class="form-group">
-		<div class="col-sm-12">
-			<textarea name="text" class="form-control" rows="3" placeholder="<?php echo $this->t('report_explain'); ?>"></textarea>
-		</div>
-	</div>
-
-	<button type="submit" name="send" class="btn btn-primary"><?php echo $this->t('report_submit'); ?></button>
-
-    </form>
-
-  </div>
-</div>
+    ?>
+    <br>
+    <div class="panel panel-default">
+        <div class="panel-heading">
+            <h3 class="panel-title"><?php echo $this->t('report_header'); ?></h3>
+        </div>
+        <div class="panel-body">
+
+            <form action="<?php echo htmlspecialchars($this->data['errorReportAddress']); ?>" method="post"
+                  class="form-horizontal">
+
+                <div class="form-group">
+                    <label class="col-sm-2 control-label"
+                           for="reportId"><?php echo $this->t('{bbmri:bbmri:error_id}'); ?></label>
+                    <div class="col-sm-10">
+                        <input name="reportId" type="text" class="form-control" id="reportId"
+                               value="<?php echo $this->data['error']['reportId']; ?>" readonly>
+                    </div>
+                </div>
+
+                <div class="form-group">
+                    <label class="col-sm-2 control-label" for="email"><?php echo $this->t('report_email'); ?></label>
+                    <div class="col-sm-10">
+                        <input name="email" type="email" class="form-control" id="email" placeholder="Email" required>
+                        <span class="help-block">
+                            <?php echo $this->t('{bbmri:bbmri:error_report_email_message}'); ?>
+                        </span>
+                    </div>
+                </div>
+
+                <div class="form-group">
+                    <div class="col-sm-12">
+                        <textarea name="text" class="form-control" rows="3"
+                                  placeholder="<?php echo $this->t('report_explain'); ?>"></textarea>
+                    </div>
+                </div>
+
+                <button type="submit" name="send"
+                        class="btn btn-primary"><?php echo $this->t('report_submit'); ?>
+                </button>
+
+            </form>
+
+        </div>
+    </div>
     <?php
 }
-?>
 
-<?php
 $this->includeAtTemplateBase('includes/footer.php');
diff --git a/themes/bbmri/default/errorreport.php b/themes/bbmri/default/errorreport.php
index f2b6962e2dc86d95d18fef42e81f64be3295e894..c69d5a76d3df1eabf63c622664418aa9ec09951b 100644
--- a/themes/bbmri/default/errorreport.php
+++ b/themes/bbmri/default/errorreport.php
@@ -1,8 +1,10 @@
 <?php
-	$this->data['header'] = $this->t('errorreport_header');
-	$this->includeAtTemplateBase('includes/header.php');
+
+$this->data['header'] = $this->t('errorreport_header');
+$this->includeAtTemplateBase('includes/header.php');
+
 ?>
 
-<p><?php echo $this->t('errorreport_text'); ?></p>
+    <p><?php echo $this->t('errorreport_text'); ?></p>
 
 <?php $this->includeAtTemplateBase('includes/footer.php');
diff --git a/themes/bbmri/default/includes/footer.php b/themes/bbmri/default/includes/footer.php
index a90c71ab12d02951e839d8d6e9b892a4e337e9fa..56edfe592d48208d759da8fcf11aa0fc256754fb 100644
--- a/themes/bbmri/default/includes/footer.php
+++ b/themes/bbmri/default/includes/footer.php
@@ -1,8 +1,11 @@
 <?php
-if(!empty($this->data['htmlinject']['htmlContentPost'])) {
-	foreach($this->data['htmlinject']['htmlContentPost'] AS $c) {
-		echo $c;
-	}
+
+use SimpleSAML\Module;
+
+if (!empty($this->data['htmlinject']['htmlContentPost'])) {
+    foreach ($this->data['htmlinject']['htmlContentPost'] as $c) {
+        echo $c;
+    }
 }
 ?>
 </div><!-- #content -->
@@ -12,21 +15,22 @@ if(!empty($this->data['htmlinject']['htmlContentPost'])) {
 
     <div style="margin: 0px auto; max-width: 1000px;">
 
-	<div style="float: left;">
-		<img src="<?php echo SimpleSAML\Module::getModuleUrl('bbmri/res/img/BBMRI-ERIC-gateway-for-health_216.png') ?>">
-	</div>
-	
-	<div style="float: left;">
-		<p>BBMRI-ERIC, Neue Stiftingtalstrasse 2/B/6, 8010 Graz, Austria
-			&nbsp; &nbsp; +43 316 34 99 17-0 &nbsp;
-			<a href="mailto:contact@bbmri_eric.eu">contact@bbmri_eric.eu</a>
-		</p>
-		<p>Copyright © BBMRI-ERIC <?php echo date("Y"); ?> </p>
-	</div>
+        <div style="float: left;">
+            <img src="<?php echo Module::getModuleUrl(
+                'bbmri/res/img/BBMRI-ERIC-gateway-for-health_216.png'
+            ) ?>">
+        </div>
+
+        <div style="float: left;">
+            <p>BBMRI-ERIC, Neue Stiftingtalstrasse 2/B/6, 8010 Graz, Austria
+                &nbsp; &nbsp; +43 316 34 99 17-0 &nbsp;
+                <a href="mailto:contact@bbmri_eric.eu">contact@bbmri_eric.eu</a>
+            </p>
+            <p>Copyright © BBMRI-ERIC <?php echo date("Y"); ?> </p>
+        </div>
     </div>
-	
+
 </div><!-- #footer -->
 
 </body>
 </html>
-
diff --git a/themes/bbmri/default/includes/header.php b/themes/bbmri/default/includes/header.php
index 9ede699be457aed39aba147cfdc236b84728dff0..0fb265aca5109787238b514912c17f52df555337 100644
--- a/themes/bbmri/default/includes/header.php
+++ b/themes/bbmri/default/includes/header.php
@@ -1,30 +1,31 @@
 <?php
 
-
+use SimpleSAML\Module;
 
 /**
  * Support the htmlinject hook, which allows modules to change header, pre and post body on all pages.
  */
 $this->data['htmlinject'] = array(
-	'htmlContentPre' => array(),
-	'htmlContentPost' => array(),
-	'htmlContentHead' => array(),
+    'htmlContentPre' => array(),
+    'htmlContentPost' => array(),
+    'htmlContentHead' => array(),
 );
 
-
 $jquery = array();
-if (array_key_exists('jquery', $this->data)) $jquery = $this->data['jquery'];
+if (array_key_exists('jquery', $this->data)) {
+    $jquery = $this->data['jquery'];
+}
 
 if (array_key_exists('pageid', $this->data)) {
-	$hookinfo = array(
-		'pre' => &$this->data['htmlinject']['htmlContentPre'], 
-		'post' => &$this->data['htmlinject']['htmlContentPost'], 
-		'head' => &$this->data['htmlinject']['htmlContentHead'], 
-		'jquery' => &$jquery, 
-		'page' => $this->data['pageid']
-	);
-		
-	SimpleSAML\Module::callHooks('htmlinject', $hookinfo);	
+    $hookinfo = array(
+        'pre' => &$this->data['htmlinject']['htmlContentPre'],
+        'post' => &$this->data['htmlinject']['htmlContentPost'],
+        'head' => &$this->data['htmlinject']['htmlContentHead'],
+        'jquery' => &$jquery,
+        'page' => $this->data['pageid']
+    );
+
+    Module::callHooks('htmlinject', $hookinfo);
 }
 // - o - o - o - o - o - o - o - o - o - o - o - o -
 
@@ -39,113 +40,116 @@ if (array_key_exists('pageid', $this->data)) {
  */
 header('X-Frame-Options: SAMEORIGIN');
 
-?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" />
-<script type="text/javascript" src="/<?php echo $this->data['baseurlpath']; ?>resources/script.js"></script>
-<title><?php
-if(array_key_exists('header', $this->data)) {
-	echo $this->data['header'];
-} else {
-	echo 'SimpleSAMLphp';
-}
-?></title>
-
-	<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default.css" />
-	<link rel="icon" type="image/icon" href="<?php echo SimpleSAML\Module::getModuleUrl('bbmri/res/img/icons/favicon.ico'); ?>" />
-
-<?php
-
-if(!empty($jquery)) {
-	$version = '1.8';
-	if (array_key_exists('version', $jquery))
-		$version = $jquery['version'];
-		
-	if ($version == '1.8') {
-		if (isset($jquery['core']) && $jquery['core'])
-			echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery-1.8.js"></script>' . "\n");
-	
-		if (isset($jquery['ui']) && $jquery['ui'])
-			echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery-ui-1.8.js"></script>' . "\n");
-	
-		if (isset($jquery['css']) && $jquery['css'])
-			echo('<link rel="stylesheet" media="screen" type="text/css" href="/' . $this->data['baseurlpath'] . 
-				'resources/uitheme1.8/jquery-ui.css" />' . "\n");
-	}
-}
-
-if (isset($this->data['clipboard.js'])) {
-	echo '<script type="text/javascript" src="/'. $this->data['baseurlpath'] .
-		 'resources/clipboard.min.js"></script>'."\n";
-}
-
-if(!empty($this->data['htmlinject']['htmlContentHead'])) {
-	foreach($this->data['htmlinject']['htmlContentHead'] AS $c) {
-		echo $c;
-	}
-}
-
-
-
-
-if ($this->isLanguageRTL()) {
-?>
-	<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" />
-<?php	
-}
-?>
-
-        <link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('bbmri/res/bootstrap/css/bootstrap.min.css'); ?>" />
-        <link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('bbmri/res/css/bbmri.css'); ?>" />
-	
-	<meta name="robots" content="noindex, nofollow" />
-	
-
-<?php	
-if(array_key_exists('head', $this->data)) {
-	echo '<!-- head -->' . $this->data['head'] . '<!-- /head -->';
-}
-?>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"/>
+    <script type="text/javascript" src="/<?php echo $this->data['baseurlpath']; ?>resources/script.js"></script>
+    <title><?php
+    if (array_key_exists('header', $this->data)) {
+            echo $this->data['header'];
+    } else {
+            echo 'SimpleSAMLphp';
+    }
+    ?></title>
+
+    <link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default.css"/>
+    <link rel="icon" type="image/icon"
+          href="<?php echo Module::getModuleUrl('bbmri/res/img/icons/favicon.ico'); ?>"/>
+
+    <?php
+
+    if (!empty($jquery)) {
+        $version = '1.8';
+        if (array_key_exists('version', $jquery)) {
+            $version = $jquery['version'];
+        }
+
+        if ($version == '1.8') {
+            if (isset($jquery['core']) && $jquery['core']) {
+                echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] .
+                    'resources/jquery-1.8.js"></script>' . "\n");
+            }
+
+            if (isset($jquery['ui']) && $jquery['ui']) {
+                echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] .
+                    'resources/jquery-ui-1.8.js"></script>' . "\n");
+            }
+
+            if (isset($jquery['css']) && $jquery['css']) {
+                echo('<link rel="stylesheet" media="screen" type="text/css" href="/' . $this->data['baseurlpath'] .
+                    'resources/uitheme1.8/jquery-ui.css" />' . "\n");
+            }
+        }
+    }
+
+    if (isset($this->data['clipboard.js'])) {
+        echo '<script type="text/javascript" src="/' . $this->data['baseurlpath'] .
+            'resources/clipboard.min.js"></script>' . "\n";
+    }
+
+    if (!empty($this->data['htmlinject']['htmlContentHead'])) {
+        foreach ($this->data['htmlinject']['htmlContentHead'] as $c) {
+            echo $c;
+        }
+    }
+
+    if ($this->isLanguageRTL()) {
+        ?>
+        <link rel="stylesheet" type="text/css"
+              href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css"/>
+        <?php
+    }
+    ?>
+
+    <link rel="stylesheet" type="text/css"
+          href="<?php echo Module::getModuleUrl('bbmri/res/bootstrap/css/bootstrap.min.css'); ?>"/>
+    <link rel="stylesheet" type="text/css"
+          href="<?php echo Module::getModuleUrl('bbmri/res/css/bbmri.css'); ?>"/>
+
+    <meta name="robots" content="noindex, nofollow"/>
+
+    <?php
+    if (array_key_exists('head', $this->data)) {
+        echo '<!-- head -->' . $this->data['head'] . '<!-- /head -->';
+    }
+    ?>
 </head>
 <?php
 $onLoad = '';
-if(array_key_exists('autofocus', $this->data)) {
-	$onLoad .= 'SimpleSAML_focus(\'' . $this->data['autofocus'] . '\');';
+if (array_key_exists('autofocus', $this->data)) {
+    $onLoad .= 'SimpleSAML_focus(\'' . $this->data['autofocus'] . '\');';
 }
 if (isset($this->data['onLoad'])) {
-	$onLoad .= $this->data['onLoad']; 
+    $onLoad .= $this->data['onLoad'];
 }
 
-if($onLoad !== '') {
-	$onLoad = ' onload="' . $onLoad . '"';
+if ($onLoad !== '') {
+    $onLoad = ' onload="' . $onLoad . '"';
 }
 ?>
 <body<?php echo $onLoad; ?>>
 
-
-
 <div id="wrap">
-	
-	<div id="header">
-		<img src="<?php echo SimpleSAML\Module::getModuleUrl('bbmri/res/img/BBMRI-ERIC-gateway-for-health_430.png'); ?>" alt="BBMRI-ERIC logo">
-		<h1>
-		<?php 
-			echo (isset($this->data['header']) ? $this->data['header'] : 'BBMRI-ERIC proxy IdP');
-		?>
-		</h1>
-	</div>
-
-	
-	<div id="content">
 
+    <div id="header">
+        <img src="<?php echo Module::getModuleUrl('bbmri/res/img/BBMRI-ERIC-gateway-for-health_430.png'); ?>"
+             alt="BBMRI-ERIC logo">
+        <h1>
+            <?php
+            echo(isset($this->data['header']) ? $this->data['header'] : 'BBMRI-ERIC proxy IdP');
+            ?>
+        </h1>
+    </div>
 
+    <div id="content">
 
 <?php
 
-if(!empty($this->data['htmlinject']['htmlContentPre'])) {
-	foreach($this->data['htmlinject']['htmlContentPre'] AS $c) {
-		echo $c;
-	}
+if (!empty($this->data['htmlinject']['htmlContentPre'])) {
+    foreach ($this->data['htmlinject']['htmlContentPre'] as $c) {
+        echo $c;
+    }
 }
diff --git a/themes/bbmri/default/post.php b/themes/bbmri/default/post.php
index 8cc1c17bc217f724896050d147ae11476f289593..74b658b70156c79d6e888454ea6ea0b18aaa5cdc 100644
--- a/themes/bbmri/default/post.php
+++ b/themes/bbmri/default/post.php
@@ -2,69 +2,74 @@
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
-	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-	<title>POST data</title>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <title>POST data</title>
 </head>
 <body onload="document.getElementsByTagName('input')[0].click();">
 
-	<noscript>
-		<p><strong><?php echo $this->t('{bbmri:bbmri:note}'); ?></strong><?php echo $this->t('{bbmri:bbmri:browser_not_support_javascript}'); ?></p>
-	</noscript> 
-	
-	<form method="post" action="<?php echo htmlspecialchars($this->data['destination']); ?>">
-	<!-- Need to add this element and call click method, because calling submit()
-	on the form causes failed submission if the form has another element with name or id of submit.
-	See: https://developer.mozilla.org/en/DOM/form.submit#Specification -->
-	<input type="submit" style="display:none;" />
-<?php
-if (array_key_exists('post', $this->data)) {
-	$post = $this->data['post'];
-} else {
-	// For backwards compatibility
-	assert('array_key_exists("response", $this->data)');
-	assert('array_key_exists("RelayStateName", $this->data)');
-	assert('array_key_exists("RelayState", $this->data)');
+<noscript>
+    <p>
+        <strong><?php echo $this->t('{bbmri:bbmri:note}'); ?></strong>
+        <?php echo $this->t('{bbmri:bbmri:browser_not_support_javascript}'); ?>
+    </p>
+</noscript>
 
-	$post = array(
-		'SAMLResponse' => $this->data['response'],
-		$this->data['RelayStateName'] => $this->data['RelayState'],
-	);
-}
+<form method="post" action="<?php echo htmlspecialchars($this->data['destination']); ?>">
+    <!-- Need to add this element and call click method, because calling submit()
+    on the form causes failed submission if the form has another element with name or id of submit.
+    See: https://developer.mozilla.org/en/DOM/form.submit#Specification -->
+    <input type="submit" style="display:none;"/>
+    <?php
+    if (array_key_exists('post', $this->data)) {
+        $post = $this->data['post'];
+    } else {
+        // For backwards compatibility
+        assert('array_key_exists("response", $this->data)');
+        assert('array_key_exists("RelayStateName", $this->data)');
+        assert('array_key_exists("RelayState", $this->data)');
 
-/**
- * Write out one or more INPUT elements for the given name-value pair.
- *
- * If the value is a string, this function will write a single INPUT element.
- * If the value is an array, it will write multiple INPUT elements to
- * recreate the array.
- *
- * @param string $name  The name of the element.
- * @param string|array $value  The value of the element.
- */
-function printItem($name, $value) {
-	assert('is_string($name)');
-	assert('is_string($value) || is_array($value)');
+        $post = array(
+            'SAMLResponse' => $this->data['response'],
+            $this->data['RelayStateName'] => $this->data['RelayState'],
+        );
+    }
 
-	if (is_string($value)) {
-		echo '<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />';
-		return;
-	}
+    /**
+     * Write out one or more INPUT elements for the given name-value pair.
+     *
+     * If the value is a string, this function will write a single INPUT element.
+     * If the value is an array, it will write multiple INPUT elements to
+     * recreate the array.
+     *
+     * @param string $name The name of the element.
+     * @param string|array $value The value of the element.
+     */
+    function printItem($name, $value)
+    {
+        assert('is_string($name)');
+        assert('is_string($value) || is_array($value)');
 
-	// This is an array...
-	foreach ($value as $index => $item) {
-		printItem($name . '[' . $index . ']', $item);
-	}
-}
+        if (is_string($value)) {
+            echo '<input type="hidden" name="' . htmlspecialchars($name) . '" value="' .
+                htmlspecialchars($value) . '" />';
+            return;
+        }
 
-foreach ($post as $name => $value) {
-	printItem($name, $value);
-}
-?>
+        // This is an array...
+        foreach ($value as $index => $item) {
+            printItem($name . '[' . $index . ']', $item);
+        }
+    }
 
-		<noscript>
-			<button type="submit" class="btn">Submit</button>
-		</noscript>
-	</form>
+    foreach ($post as $name => $value) {
+        printItem($name, $value);
+    }
+    ?>
+
+    <noscript>
+        <button type="submit" class="btn">Submit</button>
+    </noscript>
+</form>
 
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/themes/bbmri/perun/disco-tpl.php b/themes/bbmri/perun/disco-tpl.php
index 5822bcdd79c48cf256d2833d7b6501490459bc6d..1b8e1c543f5b0510d366dbcd03c1f8c6279b430e 100644
--- a/themes/bbmri/perun/disco-tpl.php
+++ b/themes/bbmri/perun/disco-tpl.php
@@ -1,19 +1,32 @@
 <?php
 
+use SimpleSAML\Module;
+use SimpleSAML\Configuration;
+use SimpleSAML\Logger;
+use SimpleSAML\Error\Exception;
+use SimpleSAML\Utils\HTTP;
+use SimpleSAML\Module\perun\DiscoTemplate;
+
 /**
  * This is simple example of template for perun Discovery service
  *
  * Allow type hinting in IDE
- * @var sspmod_perun_DiscoTemplate $this
+ * @var DiscoTemplate $this
  */
 
-$this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE);
+$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true);
+
+$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' .
+    Module::getModuleUrl('discopower/assets/css/disco.css') . '" />';
+
+$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
+    Module::getModuleUrl('bbmri/res/css/disco.css') . '" />';
 
-$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('discopower/style.css')  . '" />';
-$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('bbmri/res/css/disco.css')  . '" />';
+$this->data['head'] .= '<script type="text/javascript" src="' .
+    Module::getModuleUrl('discopower/assets/js/jquery.livesearch.js') . '"></script>';
 
-$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/jquery.livesearch.js')  . '"></script>';
-$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/suggest.js')  . '"></script>';
+$this->data['head'] .= '<script type="text/javascript" src="' .
+    Module::getModuleUrl('discopower/assets/js/suggest.js') . '"></script>';
 
 $this->data['head'] .= searchScript();
 
@@ -35,166 +48,157 @@ $warningText = null;
 $config = null;
 
 try {
-	$config = SimpleSAML_Configuration::getConfig(WARNING_CONFIG_FILE_NAME);
-} catch (Exception $ex) {
-	SimpleSAML\Logger::warning("bbmri:disco-tpl: missing or invalid config-warning file");
+    $config = Configuration::getConfig(WARNING_CONFIG_FILE_NAME);
+} catch (\Exception $ex) {
+    Logger::warning("bbmri:disco-tpl: missing or invalid config-warning file");
 }
 
 if ($config != null) {
-	try {
-		$warningIsOn = $config->getBoolean(WARNING_IS_ON);
-	} catch (Exception $ex) {
-		SimpleSAML\Logger::warning("bbmri:disco-tpl: missing or invalid isOn parameter in config-warning file");
-		$warningIsOn = false;
-	}
+    try {
+        $warningIsOn = $config->getBoolean(WARNING_IS_ON);
+    } catch (\Exception $ex) {
+        Logger::warning("bbmri:disco-tpl: missing or invalid isOn parameter in config-warning file");
+        $warningIsOn = false;
+    }
 }
 
 if ($warningIsOn) {
-	try {
-		$warningUserCanContinue = $config->getBoolean(WARNING_USER_CAN_CONTINUE);
-	} catch (Exception $ex) {
-		SimpleSAML\Logger::warning("bbmri:disco-tpl: missing or invalid userCanContinue parameter in config-warning file");
-		$warningUserCanContinue = true;
-	}
-	try {
-		$warningTitle = $config->getString(WARNING_TITLE);
-		$warningText = $config->getString(WARNING_TEXT);
-		if (empty($warningTitle) || empty($warningText)) {
-			throw new Exception();
-		}
-	} catch (Exception $ex) {
-		SimpleSAML\Logger::warning("bbmri:disco-tpl: missing or invalid title or text in config-warning file");
-		$warningIsOn = false;
-	}
+    try {
+        $warningUserCanContinue = $config->getBoolean(WARNING_USER_CAN_CONTINUE);
+    } catch (\Exception $ex) {
+        Logger::warning(
+            "bbmri:disco-tpl: missing or invalid userCanContinue parameter in config-warning file"
+        );
+        $warningUserCanContinue = true;
+    }
+    try {
+        $warningTitle = $config->getString(WARNING_TITLE);
+        $warningText = $config->getString(WARNING_TEXT);
+        if (empty($warningTitle) || empty($warningText)) {
+            throw new Exception();
+        }
+    } catch (Exception $ex) {
+        Logger::warning("bbmri:disco-tpl: missing or invalid title or text in config-warning file");
+        $warningIsOn = false;
+    }
 }
 
 if (isset($this->data['AuthnContextClassRef'])) {
-	$authContextClassRef = $this->data['AuthnContextClassRef'];
+    $authContextClassRef = $this->data['AuthnContextClassRef'];
 }
 
 # Do not show social IdPs when using addInstitutionApp, show just header Add Institution
 if ($this->isAddInstitutionApp()) {
-	// Translate title in header
-	$this->data['header'] = $this->t('{bbmri:bbmri:add_institution}');
-	$this->includeAtTemplateBase('includes/header.php');
+    // Translate title in header
+    $this->data['header'] = $this->t('{bbmri:bbmri:add_institution}');
+    $this->includeAtTemplateBase('includes/header.php');
 } else {
+    if ($warningIsOn && !$warningUserCanContinue) {
+        $this->data['header'] = $this->t('{bbmri:bbmri:warning}');
+    }
 
-	if ($warningIsOn && !$warningUserCanContinue) {
-		$this->data['header'] = $this->t('{bbmri:bbmri:warning}');
-	}
-
-
-	$this->includeAtTemplateBase('includes/header.php');
-
-	if ($authContextClassRef != null) {
-		foreach ($authContextClassRef as $value) {
-			if (substr($value, 0, strlen(URN_CESNET_PROXYIDP_IDPENTITYID)) === URN_CESNET_PROXYIDP_IDPENTITYID) {
-				$idpEntityId = substr($value, strlen(URN_CESNET_PROXYIDP_IDPENTITYID), strlen($value));
-				SimpleSAML\Logger::info("Redirecting to " . $idpEntityId);
-				$url = $this->getContinueUrl($idpEntityId);
-				SimpleSAML\Utils\HTTP::redirectTrustedURL($url);
-				exit;
-			}
-		}
-	}
-
-	if ($warningIsOn) {
-		if ($warningUserCanContinue) {
-			echo '<div class="alert alert-warning">';
-		} else {
-			echo '<div class="alert alert-danger">';
-		}
-		echo '<h4> <strong>' . $warningTitle . '</strong> </h4>';
-		echo $warningText;
-		echo '</div>';
-	}
-
-	if (!$warningIsOn || $warningUserCanContinue) {
-		if (!empty($this->getPreferredIdp())) {
-
-			echo '<p class="descriptionp">' . $this->t('{bbmri:bbmri:previous_selection}') . '</p>';
-			echo '<div class="metalist list-group">';
-			echo showEntry($this, $this->getPreferredIdp(), true);
-			echo '</div>';
-
-
-			echo getOr();
-		}
-
+    $this->includeAtTemplateBase('includes/header.php');
+
+    if ($authContextClassRef != null) {
+        foreach ($authContextClassRef as $value) {
+            if (substr($value, 0, strlen(URN_CESNET_PROXYIDP_IDPENTITYID))
+                === URN_CESNET_PROXYIDP_IDPENTITYID) {
+                $idpEntityId = substr($value, strlen(URN_CESNET_PROXYIDP_IDPENTITYID), strlen($value));
+                Logger::info("Redirecting to " . $idpEntityId);
+                $url = $this->getContinueUrl($idpEntityId);
+                HTTP::redirectTrustedURL($url);
+                exit;
+            }
+        }
+    }
 
-		echo '<div class="row">';
-		foreach ($this->getIdps('social') AS $idpentry) {
+    if ($warningIsOn) {
+        if ($warningUserCanContinue) {
+            echo '<div class="alert alert-warning">';
+        } else {
+            echo '<div class="alert alert-danger">';
+        }
+        echo '<h4> <strong>' . $warningTitle . '</strong> </h4>';
+        echo $warningText;
+        echo '</div>';
+    }
 
-			echo '<div class="col-md-4">';
-			echo '<div class="metalist list-group">';
-			echo showEntry($this, $idpentry, false);
-			echo '</div>';
-			echo '</div>';
+    if (!$warningIsOn || $warningUserCanContinue) {
+        if (!empty($this->getPreferredIdp())) {
+            echo '<p class="descriptionp">' . $this->t('{bbmri:bbmri:previous_selection}') . '</p>';
+            echo '<div class="metalist list-group">';
+            echo showEntry($this, $this->getPreferredIdp(), true);
+            echo '</div>';
 
-		}
-		echo '</div>';
 
+            echo getOr();
+        }
 
-		echo getOr();
+        echo '<div class="row">';
+        foreach ($this->getIdps('social') as $idpentry) {
+            echo '<div class="col-md-4">';
+            echo '<div class="metalist list-group">';
+            echo showEntry($this, $idpentry, false);
+            echo '</div>';
+            echo '</div>';
+        }
+        echo '</div>';
 
+        echo getOr();
 
-		echo '<p class="descriptionp">';
-		echo $this->t('{bbmri:bbmri:institutional_account}');
-		echo '</p>';
-	}
+        echo '<p class="descriptionp">';
+        echo $this->t('{bbmri:bbmri:institutional_account}');
+        echo '</p>';
+    }
 }
 
 if (!$warningIsOn || $warningUserCanContinue) {
     echo '<div class="inlinesearch">';
     echo '	<form id="idpselectform" action="?" method="get">
-			<input class="inlinesearchf form-control input-lg" placeholder="' . $this->t('{bbmri:bbmri:type_name_institution}') . '" 
-			type="text" value="" name="query" id="query" autofocus oninput="document.getElementById(\'list\').style.display=\'block\';"/>
+			<input class="inlinesearchf form-control input-lg" placeholder="' .
+            $this->t('{bbmri:bbmri:type_name_institution}') . '" 
+			type="text" value="" name="query" id="query" autofocus ' .
+            'oninput="document.getElementById(\'list\').style.display=\'block\';"/>
 		</form>';
     echo '</div>';
 
-
     echo '<div class="metalist list-group" id="list">';
-    foreach ($this->getIdps() AS $idpentry) {
+    foreach ($this->getIdps() as $idpentry) {
         echo showEntry($this, $idpentry, false);
     }
     echo '</div>';
 
-
     echo '<br>';
     echo '<br>';
 
-
     echo '<div class="no-idp-found alert alert-info">';
     if ($this->isAddInstitutionApp()) {
-        echo $this->t('{bbmri:bbmri:cannot_find_institution}') . '<a href="mailto:aai-infrastructure@lists.bbmri-eric.eu?subject=Request%20for%20adding%20new%20IdP">aai-infrastructure@lists.bbmri-eric.eu</a>';
+        echo $this->t('{bbmri:bbmri:cannot_find_institution}') .
+            '<a href="mailto:aai-infrastructure@lists.bbmri-eric.eu?subject=Request%20for%20adding%20new%20IdP">
+                aai-infrastructure@lists.bbmri-eric.eu
+            </a>';
         echo '<div class="metalist list-group">';
-        echo '<a class="btn btn-block social" href="https://adm.hostel.eduid.cz/registrace/k1" style="background: #43554a">';
+        echo '<a class="btn btn-block social"' .
+                'href="https://adm.hostel.eduid.cz/registrace/k1" style="background: #43554a">';
         echo '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IAr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62IKZMzGZTAKMzfT6U3sJKvBTEcEeZ8dkNv1DBBVFYd++fcMWF30Hk5ycTGpaWrdqoBjAFPD5XYZh3OZyuVj69DLF2v/j5Tea8ry8PO6+8y42vruR5qYmYlfZY/f1rSgKNpuNpKSkK+oGigCUgM8/rbOz8/A7721kyo034nA4iIuLG6Dh6hsa5ML580p7ezsxVcVkMmO1WbFabVgsJnRd0LUrexIUMJkU3t/4PpWVleTk5DAhdwITcnPx+Xx4Ujx4PCmDFskzv/gFWzZvwTCMs6DkKxnp3mVut/vXx058NsAgHA7zzv+8zRvr1tHY2IiiKALEumW3uU+RXZMK1zSNouIiXnhpJQkJI3qvR6NRVFXllZdf5vevrsFut0+wmEymC5faLx3JzsjMTklJcbndbiw2K+2X2jvPVFTUAmccDsc2q9X6UVVNdf0QH8vtKDhFGKEoJAJJ3T3NA3gERipCgsVisW7dstVTtqdsalHxXH/BzAJGjxmN0+nEMAS/34+hG4hwm9K9J3Hquu7Sdd0hhlgNMWKKokTtdvtlk8kUqqqpNv6/W0p2hk+JRFS3iOTbbLb74uPjbzSbzaMMEV3t6rqoadpuBX7/f8CzYtolwEc1AAAAAElFTkSuQmCC">';
         echo '<strong>' . $this->t('{bbmri:bbmri:create_account_hostel}') . '</strong>';
         echo '</a>';
-	    echo '</div>';
+        echo '</div>';
     } else {
-        echo $this->t('{bbmri:bbmri:cannot_find_institution_extended}') . '<a class="btn btn-primary" href="https://login.bbmri-eric.eu/add-institution/">' . $this->t('{bbmri:bbmri:add_institution}') . '</a>';
+        echo $this->t('{bbmri:bbmri:cannot_find_institution_extended}') .
+            '<a class="btn btn-primary" href="https://login.bbmri-eric.eu/add-institution/">' .
+                $this->t('{bbmri:bbmri:add_institution}') .
+            '</a>';
     }
     echo '</div>';
 }
 
-
-
-
-
 $this->includeAtTemplateBase('includes/footer.php');
 
+function searchScript()
+{
 
-
-
-
-
-
-
-function searchScript() {
-
-	$script = '<script type="text/javascript">
+    $script = '<script type="text/javascript">
 
 	$(document).ready(function() { 
 		$("#query").liveUpdate("#list");
@@ -202,75 +206,83 @@ function searchScript() {
 	
 	</script>';
 
-	return $script;
+    return $script;
 }
 
 /**
- * @param sspmod_perun_DiscoTemplate $t
+ * @param DiscoTemplate $t
  * @param array $metadata
  * @param bool $favourite
  * @return string html
  */
-function showEntry($t, $metadata, $favourite = false) {
+function showEntry($t, $metadata, $favourite = false)
+{
 
-	if (isset($metadata['tags']) && in_array('social', $metadata['tags'])) {
-		return showEntrySocial($t, $metadata);
-	}
+    if (isset($metadata['tags']) && in_array('social', $metadata['tags'])) {
+        return showEntrySocial($t, $metadata);
+    }
 
-	$extra = ($favourite ? ' favourite' : '');
-	$html = '<a class="metaentry' . $extra . ' list-group-item" href="' . $t->getContinueUrl($metadata['entityid']) . '">';
+    $extra = ($favourite ? ' favourite' : '');
+    $html = '<a class="metaentry' . $extra . ' list-group-item" href="' .
+        $t->getContinueUrl($metadata['entityid']) . '">';
 
-	$html .= '<strong>' . $t->getTranslatedEntityName($metadata) . '</strong>';
+    $html .= '<strong>' . $t->getTranslatedEntityName($metadata) . '</strong>';
 
-	$html .= showIcon($metadata);
+    $html .= showIcon($metadata);
 
-	$html .= '</a>';
+    $html .= '</a>';
 
-	return $html;
+    return $html;
 }
 
 /**
- * @param sspmod_perun_DiscoTemplate $t
+ * @param DiscoTemplate $t
  * @param array $metadata
  * @return string html
  */
-function showEntrySocial($t, $metadata) {
+function showEntrySocial($t, $metadata)
+{
 
-	$bck = 'white';
-	if (!empty($metadata['color'])) {
-		$bck = $metadata['color'];
-	}
+    $bck = 'white';
+    if (!empty($metadata['color'])) {
+        $bck = $metadata['color'];
+    }
 
-	$html = '<a class="btn btn-block social" href="' . $t->getContinueUrl($metadata['entityid'])  . '" style="background: '. $bck .'">';
+    $html = '<a class="btn btn-block social" href="' . $t->getContinueUrl($metadata['entityid']) .
+        '" style="background: ' . $bck . '">';
 
-	$html .= '<img src="' . $metadata['icon'] . '">';
+    $html .= '<img src="' . $metadata['icon'] . '">';
 
-	$html .= '<strong>Sign in with ' . $t->getTranslatedEntityName($metadata) . '</strong>';
+    $html .= '<strong>Sign in with ' . $t->getTranslatedEntityName($metadata) . '</strong>';
 
-	$html .= '</a>';
+    $html .= '</a>';
 
-	return $html;
+    return $html;
 }
 
 
-function showIcon($metadata) {
-	$html = '';
-	// Logos are turned off, because they are loaded via URL from IdP. Some IdPs have bad configuration, so it breaks the WAYF.
+function showIcon($metadata)
+{
+    $html = '';
+    // Logos are turned off, because they are loaded via URL from IdP. Some IdPs have bad configuration,
+    // so it breaks the WAYF.
 
-	/*if (isset($metadata['UIInfo']['Logo'][0]['url'])) {
-		$html .= '<img src="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['UIInfo']['Logo'][0]['url'])) . '" class="idp-logo">';
-	} else if (isset($metadata['icon'])) {
-		$html .= '<img src="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['icon'])) . '" class="idp-logo">';
-	}*/
+    /*if (isset($metadata['UIInfo']['Logo'][0]['url'])) {
+        $html .= '<img src="' .
+                    htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['UIInfo']['Logo'][0]['url'])) .
+                    '" class="idp-logo">';
+    } else if (isset($metadata['icon'])) {
+        $html .= '<img src="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::resolveURL($metadata['icon'])) .
+                    '" class="idp-logo">';
+    }*/
 
-	return $html;
+    return $html;
 }
 
-
-function getOr() {
-	$or  = '<div class="hrline">';
-	$or .= '	<span>or</span>';
-	$or .= '</div>';
-	return $or;
+function getOr()
+{
+    $or = '<div class="hrline">';
+    $or .= '	<span>or</span>';
+    $or .= '</div>';
+    return $or;
 }
-