diff --git a/src/adjmat/AdjacencyMatrixVessel.cpp b/src/adjmat/AdjacencyMatrixVessel.cpp
index 38a0f485c4dbced5b2e361fe911aa342ece7c5fa..884658a6f7ab2086ba503092097078b4ef72fc50 100644
--- a/src/adjmat/AdjacencyMatrixVessel.cpp
+++ b/src/adjmat/AdjacencyMatrixVessel.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "vesselbase/ActionWithVessel.h"
 #include "AdjacencyMatrixVessel.h"
 #include "AdjacencyMatrixBase.h" 
+#include "vesselbase/ActionWithVessel.h"
 
 namespace PLMD {
 namespace adjmat {
diff --git a/src/bias/ReweightBase.cpp b/src/bias/ReweightBase.cpp
index c517bd581331a98c4d34c153dab3545b2eee5caf..67130547654dfa05817764f88bb80818b7e0c4e0 100644
--- a/src/bias/ReweightBase.cpp
+++ b/src/bias/ReweightBase.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "ReweightBase.h"
 #include "core/PlumedMain.h"
 #include "core/Atoms.h"
-#include "ReweightBase.h"
 
 namespace PLMD {
 namespace bias {
diff --git a/src/bias/ReweightBias.cpp b/src/bias/ReweightBias.cpp
index 6a98537f82d60112c95f849442714f6f1d2e11e6..d5459df962ccd55f8b302a1990ce0fbd606f2661 100644
--- a/src/bias/ReweightBias.cpp
+++ b/src/bias/ReweightBias.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "core/ActionRegister.h"
 #include "ReweightBase.h"
+#include "core/ActionRegister.h"
 
 //+PLUMEDOC REWEIGHTING REWEIGHT_BIAS
 /*
diff --git a/src/colvar/PathMSDBase.cpp b/src/colvar/PathMSDBase.cpp
index 6a7c6edfd3ac26ac1bb8c1826ed24e8ca9938598..9b9ee99046b9ea8353625512a194d4b5af699676 100644
--- a/src/colvar/PathMSDBase.cpp
+++ b/src/colvar/PathMSDBase.cpp
@@ -19,15 +19,15 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <cmath>
-#include "Colvar.h"
 #include "PathMSDBase.h"
+#include "Colvar.h"
 #include "ActionRegister.h"
 #include "core/PlumedMain.h"
 #include "core/Atoms.h"
 #include "tools/PDB.h"
 #include "tools/RMSD.h"
 #include "tools/Tools.h"
+#include <cmath>
 
 using namespace std;
 
diff --git a/src/core/CLToolMain.cpp b/src/core/CLToolMain.cpp
index 60d8d17aa6a0a4b9d69a32c2f659ec642479ace0..09d20edc03de851c01cac43e3d4f5b1f480b03d0 100644
--- a/src/core/CLToolMain.cpp
+++ b/src/core/CLToolMain.cpp
@@ -19,11 +19,11 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "CLToolMain.h"
 #include "config/Config.h"
 #include "tools/Exception.h"
 #include "tools/Communicator.h"
 #include "CLTool.h"
-#include "CLToolMain.h"
 #include "CLToolRegister.h"
 #include "tools/Tools.h"
 #include "tools/DLLoader.h"
diff --git a/src/core/MDAtoms.cpp b/src/core/MDAtoms.cpp
index 44b618780b4d6f4c669b7970b366c4259ae7c86a..fc22bec03d6dd313f2a82fe775d418b429e122ca 100644
--- a/src/core/MDAtoms.cpp
+++ b/src/core/MDAtoms.cpp
@@ -19,12 +19,12 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <algorithm>
-#include <string>
 #include "MDAtoms.h"
 #include "tools/Tools.h"
 #include "tools/OpenMP.h"
 #include "tools/Exception.h"
+#include <algorithm>
+#include <string>
 
 using namespace std;
 
diff --git a/src/crystallization/Gradient.cpp b/src/crystallization/Gradient.cpp
index 4bd4763a27ad234d39161e8d947db8b97535c41c..cab20247624e102b0b7d39afd418a8bf60a5dc35 100644
--- a/src/crystallization/Gradient.cpp
+++ b/src/crystallization/Gradient.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "Gradient.h"
 #include "core/ActionRegister.h"
 #include "tools/HistogramBead.h"
-#include "Gradient.h"
 
 namespace PLMD {
 namespace crystallization {
diff --git a/src/crystallization/OrientationSphere.cpp b/src/crystallization/OrientationSphere.cpp
index 393463214bd5bb5a18b895aa55ba00c9cdf3b697..cd568037af2cea0275494b1017a9310011de8db1 100644
--- a/src/crystallization/OrientationSphere.cpp
+++ b/src/crystallization/OrientationSphere.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "VectorMultiColvar.h"
 #include "OrientationSphere.h"
+#include "VectorMultiColvar.h"
 
 using namespace std;
 
diff --git a/src/crystallization/Steinhardt.cpp b/src/crystallization/Steinhardt.cpp
index 19cff612ea92df77449b86c3ebc5419553865a74..038d54567161ea4c69fcf371932af6e98bf665de 100644
--- a/src/crystallization/Steinhardt.cpp
+++ b/src/crystallization/Steinhardt.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <complex>
 #include "Steinhardt.h"
+#include <complex>
 
 namespace PLMD {
 namespace crystallization {
diff --git a/src/crystallization/VectorMultiColvar.cpp b/src/crystallization/VectorMultiColvar.cpp
index 231cdb4513255d1b4c83e1b6ec29bed4a79f90e5..89652e98e95adf0ae064532fd1acd7fb1fa071fe 100644
--- a/src/crystallization/VectorMultiColvar.cpp
+++ b/src/crystallization/VectorMultiColvar.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "VectorMultiColvar.h"
 #include "multicolvar/MultiColvarFunction.h"
 #include "multicolvar/BridgedMultiColvarFunction.h"
-#include "VectorMultiColvar.h"
 
 namespace PLMD {
 namespace crystallization {
diff --git a/src/gridtools/ContourFindingBase.cpp b/src/gridtools/ContourFindingBase.cpp
index 94ae562f06c3e630e2aed9de552d1b0a90c293ec..0ce55ccc1172cbe8758531980896c4ff5776709c 100644
--- a/src/gridtools/ContourFindingBase.cpp
+++ b/src/gridtools/ContourFindingBase.cpp
@@ -19,10 +19,10 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "ContourFindingBase.h"
 #include "vesselbase/StoreDataVessel.h"
 #include "core/PlumedMain.h"
 #include "core/Atoms.h"
-#include "ContourFindingBase.h"
 
 namespace PLMD {
 namespace gridtools {
diff --git a/src/gridtools/GridVessel.cpp b/src/gridtools/GridVessel.cpp
index d62507d156be2d5d2266748c052365c4dc4df977..750b06c8e7767136e53a4c6b13432ee32c873111 100644
--- a/src/gridtools/GridVessel.cpp
+++ b/src/gridtools/GridVessel.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "GridVessel.h"
 #include "vesselbase/ActionWithVessel.h"
 #include "tools/Tools.h"
-#include "GridVessel.h"
 
 namespace PLMD {
 namespace gridtools {
diff --git a/src/gridtools/HistogramOnGrid.cpp b/src/gridtools/HistogramOnGrid.cpp
index 84bac39f833e2b1ce1da1c110d6c657aa19144a7..b227ef6937502ac810709a61980824d64ab7e0e5 100644
--- a/src/gridtools/HistogramOnGrid.cpp
+++ b/src/gridtools/HistogramOnGrid.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "tools/KernelFunctions.h"
 #include "HistogramOnGrid.h"
+#include "tools/KernelFunctions.h"
 
 namespace PLMD {
 namespace gridtools {
diff --git a/src/multicolvar/BridgedMultiColvarFunction.cpp b/src/multicolvar/BridgedMultiColvarFunction.cpp
index 1d779533ba4c24fee2d682a0fb5d7a1c431c1df1..4ee9f8f63402037d577e69516c0bf2af919703a7 100644
--- a/src/multicolvar/BridgedMultiColvarFunction.cpp
+++ b/src/multicolvar/BridgedMultiColvarFunction.cpp
@@ -19,10 +19,10 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "BridgedMultiColvarFunction.h"
 #include "core/PlumedMain.h"
 #include "core/ActionSet.h"
 #include "CatomPack.h"
-#include "BridgedMultiColvarFunction.h"
 
 namespace PLMD {
 namespace multicolvar {
diff --git a/src/reference/Direction.cpp b/src/reference/Direction.cpp
index 16c142f4c6259edebe97639fbc512dc49121ee81..9fa67bebe8dccc9b67368c2f56bbdf216c98a7f5 100644
--- a/src/reference/Direction.cpp
+++ b/src/reference/Direction.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "MetricRegister.h"
 #include "Direction.h"
+#include "MetricRegister.h"
 
 namespace PLMD {
 
diff --git a/src/reference/MultiDomainRMSD.cpp b/src/reference/MultiDomainRMSD.cpp
index 576bff6cf936c9ea35ca7556bc4486be8e691e0a..703af4ae65741cfdd9b5030a1f450a184601ed7e 100644
--- a/src/reference/MultiDomainRMSD.cpp
+++ b/src/reference/MultiDomainRMSD.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "SingleDomainRMSD.h"
 #include "MultiDomainRMSD.h"
+#include "SingleDomainRMSD.h"
 #include "MetricRegister.h"
 #include "tools/PDB.h"
 
diff --git a/src/tools/BiasRepresentation.cpp b/src/tools/BiasRepresentation.cpp
index 64b774bfa731f93c8410e5f152f0bcb1388df8f5..7d9870424089df561cfec258ff9108772c85e99d 100644
--- a/src/tools/BiasRepresentation.cpp
+++ b/src/tools/BiasRepresentation.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "BiasRepresentation.h"
 #include "core/Value.h"
 #include "Communicator.h"
-#include "BiasRepresentation.h"
 #include <iostream>
 
 namespace PLMD {
diff --git a/src/tools/Communicator.cpp b/src/tools/Communicator.cpp
index f23b30ba0eb8cb514e760ac28df580fb4471b96c..38c09ae12beec942100c197607812546688c7cc6 100644
--- a/src/tools/Communicator.cpp
+++ b/src/tools/Communicator.cpp
@@ -19,9 +19,9 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <cstdlib>
 #include "Communicator.h"
 #include "Exception.h"
+#include <cstdlib>
 
 using namespace std;
 
diff --git a/src/tools/FileBase.cpp b/src/tools/FileBase.cpp
index 6d5535f6b915bbd7a366f76a2069782f008c1d72..ff9263cd8f23fc3f015a50ddae4a21cf6b98bc13 100644
--- a/src/tools/FileBase.cpp
+++ b/src/tools/FileBase.cpp
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "FileBase.h"
+// this is required to compile test
 #include "File.h"
 #include "Exception.h"
 #include "core/Action.h"
diff --git a/src/tools/Grid.cpp b/src/tools/Grid.cpp
index 72e57be840c137e303b517a51dfc25341ea8b27e..b263ae92cc741599352fa121b47544481d67fda4 100644
--- a/src/tools/Grid.cpp
+++ b/src/tools/Grid.cpp
@@ -19,12 +19,6 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <vector>
-#include <cmath>
-#include <iostream>
-#include <sstream>
-#include <cstdio>
-#include <cfloat>
 
 #include "Grid.h"
 #include "Tools.h"
@@ -35,6 +29,13 @@
 #include "RootFindingBase.h"
 #include "Communicator.h"
 
+#include <vector>
+#include <cmath>
+#include <iostream>
+#include <sstream>
+#include <cstdio>
+#include <cfloat>
+
 using namespace std;
 namespace PLMD{
 
diff --git a/src/tools/IFile.cpp b/src/tools/IFile.cpp
index 4d1a2dcdb248eadc773efaaab242af6cb761e8ea..6518eeb2463309c1a8b4bd380cafb49526a4fa12 100644
--- a/src/tools/IFile.cpp
+++ b/src/tools/IFile.cpp
@@ -19,7 +19,7 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "File.h"
+#include "IFile.h"
 #include "Exception.h"
 #include "core/Action.h"
 #include "core/PlumedMain.h"
diff --git a/src/tools/LatticeReduction.cpp b/src/tools/LatticeReduction.cpp
index 487991d3c98351a04179d4c0a88fbb43849572ac..a04ee83f2d87f3d20d4439f24a993092625fd36d 100644
--- a/src/tools/LatticeReduction.cpp
+++ b/src/tools/LatticeReduction.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "Exception.h"
 #include "LatticeReduction.h"
+#include "Exception.h"
 #include <stdio.h>
 
 namespace PLMD{
diff --git a/src/tools/NeighborList.cpp b/src/tools/NeighborList.cpp
index ab23e06bf422bc288704a54f9bd8123ac5432a55..a07d8604d93db1f32507b52e13ca4790cac669a7 100644
--- a/src/tools/NeighborList.cpp
+++ b/src/tools/NeighborList.cpp
@@ -19,13 +19,13 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <vector>
-#include <algorithm>
+#include "NeighborList.h"
 #include "Vector.h"
 #include "Pbc.h"
 #include "AtomNumber.h"
 #include "Tools.h"
-#include "NeighborList.h"
+#include <vector>
+#include <algorithm>
 
 namespace PLMD{
 using namespace std;
diff --git a/src/tools/OFile.cpp b/src/tools/OFile.cpp
index e30bdd9e4defd6f92e8bbab07555d5f3e4916ffe..dcadbd6ca470ad3a00d3263f6efd36bf18214099 100644
--- a/src/tools/OFile.cpp
+++ b/src/tools/OFile.cpp
@@ -19,7 +19,7 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "File.h"
+#include "OFile.h"
 #include "Exception.h"
 #include "core/Action.h"
 #include "core/PlumedMain.h"
diff --git a/src/tools/Tools.cpp b/src/tools/Tools.cpp
index c1ffe96f96886c38c78d0e2094ef261265afd0a4..85e325cc512f5aadf419eda0e26283d2fa741f9e 100644
--- a/src/tools/Tools.cpp
+++ b/src/tools/Tools.cpp
@@ -19,13 +19,13 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include <iostream>
 #include "Tools.h"
 #include "AtomNumber.h"
 #include "Exception.h"
 #include "IFile.h"
 #include <cstring>
 #include <dirent.h>
+#include <iostream>
 
 using namespace std;
 namespace PLMD{
diff --git a/src/vesselbase/ActionWithVessel.cpp b/src/vesselbase/ActionWithVessel.cpp
index 46f9957dea952a6455e04deb2f1dd2eef3c9ef5c..02eb060f061b2558715ac64b43fa2d57652ab397 100644
--- a/src/vesselbase/ActionWithVessel.cpp
+++ b/src/vesselbase/ActionWithVessel.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "tools/Communicator.h"
 #include "ActionWithVessel.h"
+#include "tools/Communicator.h"
 #include "Vessel.h"
 #include "ShortcutVessel.h"
 #include "StoreDataVessel.h"
diff --git a/src/vesselbase/Between.cpp b/src/vesselbase/Between.cpp
index 74a62da44d0cd264c3911fda3a4dd7f56c3c1846..3a00b2fa70d445a8a315ebfe4d7b5701cc931a05 100644
--- a/src/vesselbase/Between.cpp
+++ b/src/vesselbase/Between.cpp
@@ -20,8 +20,8 @@
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
 
-#include "VesselRegister.h"
 #include "Between.h"
+#include "VesselRegister.h"
 
 namespace PLMD {
 namespace vesselbase {
diff --git a/src/vesselbase/LessThan.cpp b/src/vesselbase/LessThan.cpp
index 415d5637d4a07b436bdad134faf95dfdefb0c0b2..1e3c19bfadfdb8af160684ffcdab770db9339b09 100644
--- a/src/vesselbase/LessThan.cpp
+++ b/src/vesselbase/LessThan.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "VesselRegister.h"
 #include "LessThan.h"
+#include "VesselRegister.h"
 
 namespace PLMD {
 namespace vesselbase{
diff --git a/src/vesselbase/Vessel.cpp b/src/vesselbase/Vessel.cpp
index a5853344ede0ae76b0809105bb4b51a9e9478408..deec8b036dfb3cf4d7d593cc2b1bdd4e32a76b7f 100644
--- a/src/vesselbase/Vessel.cpp
+++ b/src/vesselbase/Vessel.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "ActionWithVessel.h"
 #include "Vessel.h"
+#include "ActionWithVessel.h"
 #include "tools/Exception.h"
 #include "tools/Communicator.h"
 #include "tools/Log.h"
diff --git a/src/vesselbase/VesselRegister.cpp b/src/vesselbase/VesselRegister.cpp
index 6dee40e6c3074ca23f2d7c486b8367dfaf12a66c..d2e20b31bdb79c24cecb405c551ff2e3c4aff360 100644
--- a/src/vesselbase/VesselRegister.cpp
+++ b/src/vesselbase/VesselRegister.cpp
@@ -19,8 +19,8 @@
    You should have received a copy of the GNU Lesser General Public License
    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-#include "Vessel.h"
 #include "VesselRegister.h"
+#include "Vessel.h"
 #include <iostream>
 
 namespace PLMD{