diff --git a/bin/account-manager-client.pl b/bin/account-manager-client.pl
index 86ba336d6af48ceb291de6c4d46bfbb8c4b26e3c..bb68573fdddbd32e4adb9dcff55e732a88f22e3b 100755
--- a/bin/account-manager-client.pl
+++ b/bin/account-manager-client.pl
@@ -20,13 +20,13 @@ use Pod::Usage;
 use Conf;
 use IdPAccountManager::Data::AuthenticationToken;
 use IdPAccountManager::Data::AuthenticationToken::Manager;
-use IdPAccountManager::Data::TestAccount;
-use IdPAccountManager::Data::TestAccount::Manager;
 use IdPAccountManager::Data::ServiceProvider;
 use IdPAccountManager::Data::ServiceProvider::Manager;
-use IdPAccountManager::SAMLMetadata;
+use IdPAccountManager::Data::TestAccount;
+use IdPAccountManager::Data::TestAccount::Manager;
 use IdPAccountManager::Configuration;
 use IdPAccountManager::Logger;
+use IdPAccountManager::SAMLMetadata;
 
 my %options;
 GetOptions(
diff --git a/bin/account-manager-web.pl b/bin/account-manager-web.pl
index e78662e89ccff1a33c5501c7d39e3e024fb56e44..dcf73ecd4001964783fa42244b0a933968a9146c 100755
--- a/bin/account-manager-web.pl
+++ b/bin/account-manager-web.pl
@@ -12,14 +12,6 @@ use warnings;
 use utf8;
 use lib qw(lib conf);
 
-use CGI;
-use CGI::Cookie;
-use CGI::Util;
-use Template;
-use Template::Constants qw( :debug );
-
-use IdPAccountManager::SAMLMetadata;
-
 use IdPAccountManager::Configuration;
 use IdPAccountManager::WebRequest;
 
diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm
index 7d4acf7f4c4caf8f8965c8339b7264ee5296d11c..204d90dacc7b7b1ef38aeecd8df3a5e4309154ab 100644
--- a/lib/IdPAccountManager/SAMLMetadata.pm
+++ b/lib/IdPAccountManager/SAMLMetadata.pm
@@ -8,11 +8,11 @@ use strict;
 use warnings;
 
 use English qw(-no_match_vars);
+use XML::LibXML;
+
 use IdPAccountManager::Tools;
 use IdPAccountManager::Logger;
 
-use XML::LibXML;
-
 sub new {
     my ($pkg, %args) = @_;
 
diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm
index cb76b271f232fd8b5a4426237eb5b5048ce89225..447f37678da13c04890c7a5e2b5f667592301553 100644
--- a/lib/IdPAccountManager/Tools.pm
+++ b/lib/IdPAccountManager/Tools.pm
@@ -4,13 +4,10 @@ package IdPAccountManager::Tools;
 ## This software was developed by RENATER. The research leading to these results has received funding
 ## from the European Community¹s Seventh Framework Programme (FP7/2007-2013) under grant agreement nº 238875 (GÉANT).
 
-use Template;
-
-# load Template::Stash to make method tables visible
-use Template::Stash;
-
 use Digest::SHA;
 use Encode;
+use Template;
+use Template::Stash;
 
 INIT {
     ## a TT2 virtual method to get a variable type
diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 07e5ac432939f6bc9da9ee8c10a730cbb2448679..c0cdf03204235d82085d619543a499c49a141a42 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -3,11 +3,16 @@ package IdPAccountManager::WebRequest;
 use strict;
 use warnings;
 
+use CGI;
+use CGI::Cookie;
 use English qw(-no_match_vars);
-use IdPAccountManager::Logger;
+use Template;
+
 use IdPAccountManager::Data::TestAccount;
 use IdPAccountManager::Data::AuthenticationToken;
 use IdPAccountManager::Data::ServiceProvider;
+use IdPAccountManager::Logger;
+use IdPAccountManager::SAMLMetadata;
 
 ## New web request
 sub new {