diff --git a/.travis.yml b/.travis.yml
index 55d22a7758ae1ba3444acd968c65790c500bd2de..5aaa878334355ebf7894b97059bda7ad62956f4c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,7 +24,7 @@ matrix:
   - os: linux
     dist: trusty
     sudo: required
-    env: CPPCHECK=yes CPPCHECK_VERSION=1.77
+    env: CPPCHECK=yes CPPCHECK_VERSION=1.78
 # then check with different optimization flags
   - os: linux
     dist: trusty
diff --git a/CHANGES/v2.3.txt b/CHANGES/v2.3.txt
index 68d20fde5e0977f1b757d899d8503c818e070a5c..c2928f73645a00902bff9ab34c627faf3cf01ee2 100644
--- a/CHANGES/v2.3.txt
+++ b/CHANGES/v2.3.txt
@@ -151,8 +151,12 @@ See branch \branch{v2.3} on git repository.
   with a package manager such as MacPorts.
 - Resolved problem with nan in \ref SMAC with SPECIESA and SPECIESB involving molecules that are the same
 - PDB reader is now able to read files with dos newlines (see \issue{223}).
-- fix a bug in \ref CS2BACKBONE (v2.3.1) related to ring currents of HIS and TRP
+- Fixed bug in \ref CS2BACKBONE (v2.3.1) related to ring currents of HIS and TRP
 - Fixed bug in if condition in \ref PCAVARS so that you can run with only one eigenvector defined in input 
+- Fixed bug with timers in \ref sum_hills \issue{194}.
+- Fixed bug when using \ref MOVINGRESTRAINT with periodic variables such as \ref TORSION \issue{225}.
+- Fixed bug in \ref HBONDS that used to apear when you used DONORNS and ACCEPTORS with same numbers of atoms 
+- Fixed bug in \ref DISTANCES that appears when using BETWEEN and link cells.
 
 For developers:
 - plumedcheck validation has been made stricter. All the checks are now described in the developer manual.
diff --git a/macports/Portfile.in b/macports/Portfile.in
index e69f64383b915cd2567247e37e957bb3e3a11018..a7d36b833dd7060459e29d094ed1f21a0b21fa34 100644
--- a/macports/Portfile.in
+++ b/macports/Portfile.in
@@ -11,8 +11,12 @@ PortGroup           cxx11 1.1
 version             @_VERSION_@
 revision            @_REVISION_@
 categories          science
-license             LGPL-3
-maintainers         gmail.com:giovanni.bussi
+
+# Most of the PLUMED code is L-GPL3. However, PLUMED containts
+# molfile plugins from VMD that are released with a BSD-like license
+# http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/
+license             LGPL-3 BSD
+maintainers         gmail.com:giovanni.bussi openmaintainer
 description         PLUMED is a plugin for molecular dynamics
 long_description    PLUMED is a plugin for molecular dynamics that can be used \
                     in combination with popular molecular dynamics codes to perform biased simulations. \
@@ -31,15 +35,17 @@ homepage            http://www.plumed.org/
 # - list their name here:
 
 # Disable additional features.
-# they are then re-enabled when selecting proper variants
+# They are then re-enabled when selecting proper variants
 # this is important for features that require an additional package to be
 # sure that even if the user has that package already installed plumed is
 # not going to use it.
+# Also avoid searching for doxygen.
 configure.args-append \
+               --disable-doc \
                --disable-libsearch \
-               --disable-molfile-plugins \
                --disable-mpi 
 
+
 # Hardcode path for libplumedKernel.dylib.
 # This allows to patch MD codes using the --runtime option but using as
 # default kernel the installed one. In this way, MacPorts users
@@ -54,56 +60,20 @@ if {[mpi_variant_isset]} {
   configure.args-replace --disable-mpi --enable-mpi
 }
 
-variant matheval description {Enable libmatheval} {
-  configure.ldflags-append -lmatheval
-  depends_lib-append port:libmatheval
-}
-
-variant xdrfile description {Enable xdrfile} {
-  configure.ldflags-append -lxdrfile
-  depends_lib-append port:xdrfile
-}
-
-variant zlib description {Enable zlib} {
-  configure.ldflags-append -lz
-  depends_lib-append port:zlib
-}
+# libraries
+configure.ldflags-append -lmatheval -lxdrfile -lz -lgsl
+depends_lib-append port:libmatheval port:xdrfile port:zlib port:gsl
 
-variant gsl description {Enable gsl} {
-  configure.ldflags-append -lgsl
-  depends_lib-append port:gsl
+# This variant enables optional modules in PLUMED.
+variant allmodules description {Enable all optional modules} {
+  configure.args-append --enable-modules=all
 }
 
-variant molfile description {Enable molfile - includes some BSD code} {
-  license ${license} BSD
-  configure.args-replace --disable-molfile-plugins --enable-molfile-plugins
-}
-
-variant doc description {Also compile documentation} {
-  depends_build-append port:doxygen
-  depends_build-append port:graphviz
-  build.target all_plus_docs
-}
-
-# this is a tcl variable contains a concatenated list of modules
-# to be activated
-
-set plumed_modules reset
-
-# this will automatically create variants for each optional module
-@_MODULES_@ plumed_modules
-
 pre-configure {
   # commands should be included in a pre-configure block to access tcl variables
-  configure.args-append --enable-modules=${plumed_modules}
   configure.ldflags-append ${linalglib}
 }
 
-# Default variants include no optional modules.
-# Additionally, the link libraries that are very useful (e.g. matheval of xdrfile)
-# and quick to compile
-default_variants +matheval +xdrfile +zlib +molfile
-
 # This is required since PLUMED installation does not do it explicitly.
 # It might be removed when this will be incorporated upstream
 post-destroot {
diff --git a/regtest/basic/rt-moving-restraint-pbc/COLVAR.reference b/regtest/basic/rt-moving-restraint-pbc/COLVAR.reference
new file mode 100644
index 0000000000000000000000000000000000000000..d73576ec3cc5474b5f33c03b39ddf29eaaea9c21
--- /dev/null
+++ b/regtest/basic/rt-moving-restraint-pbc/COLVAR.reference
@@ -0,0 +1,13 @@
+#! FIELDS time t d @2.bias @2.force2 @2.t_cntr @2.t_work @2.t_kappa @2.d_cntr @2.d_work @2.d_kappa @2.work
+#! SET min_t -pi
+#! SET max_t pi
+ 0.000000 -1.571  1.000  3.777  7.553  2.827  0.000  1.000  3.000  0.000  1.000  0.000
+ 1.000000 -1.571  1.000  2.536  5.073  2.897 -0.129  1.000  2.333 -1.111  1.000 -1.240
+ 2.000000 -1.571  1.000  1.745  3.491  2.967 -0.253  1.000  1.667 -1.778  1.000 -2.031
+ 3.000000 -1.571  1.000  1.404  2.807  3.037 -0.373  1.000  1.000 -2.000  1.000 -2.373
+ 4.000000 -1.571  1.000  1.511  3.023  3.107 -0.487  1.000  0.333 -1.778  1.000 -2.265
+ 5.000000 -1.571  1.000  2.068  4.137  3.176 -0.597  1.000 -0.333 -1.111  1.000 -1.708
+ 6.000000 -1.571  1.000  3.075  6.149  3.246 -0.702  1.000 -1.000  0.000  1.000 -0.702
+ 7.000000 -1.571  1.000  4.530  9.061  3.316 -0.802  1.000 -1.667  1.556  1.000  0.754
+ 8.000000 -1.571  1.000  6.435 12.871  3.386 -0.897  1.000 -2.333  3.556  1.000  2.659
+ 9.000000 -1.571  1.000  8.790 17.579 -2.827  7.128  1.000 -3.000  6.000  1.000 13.128
diff --git a/regtest/basic/rt-moving-restraint-pbc/Makefile b/regtest/basic/rt-moving-restraint-pbc/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee
--- /dev/null
+++ b/regtest/basic/rt-moving-restraint-pbc/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/basic/rt-moving-restraint-pbc/config b/regtest/basic/rt-moving-restraint-pbc/config
new file mode 100644
index 0000000000000000000000000000000000000000..620081c889fb67d157409f9a25809d93bfca355b
--- /dev/null
+++ b/regtest/basic/rt-moving-restraint-pbc/config
@@ -0,0 +1,3 @@
+type=driver
+# this is to test a different name
+arg="--plumed plumed.dat --ixyz traj.xyz --dump-forces forces --dump-forces-fmt=%8.4f"
diff --git a/regtest/basic/rt-moving-restraint-pbc/plumed.dat b/regtest/basic/rt-moving-restraint-pbc/plumed.dat
new file mode 100644
index 0000000000000000000000000000000000000000..bb96a9fe7af729e315a4578137921815f8a8146e
--- /dev/null
+++ b/regtest/basic/rt-moving-restraint-pbc/plumed.dat
@@ -0,0 +1,10 @@
+t: TORSION ATOMS=1,2,3,4
+d: DISTANCE ATOMS=1,2
+
+MOVINGRESTRAINT ...
+   ARG=t,d
+   AT0=0.9pi,3  STEP0=0 KAPPA0=1,1
+   AT1=-0.9pi,-3 STEP1=9 KAPPA1=1,1
+...
+
+PRINT ARG=* FILE=COLVAR FMT=%6.3f
diff --git a/regtest/basic/rt-moving-restraint-pbc/traj.xyz b/regtest/basic/rt-moving-restraint-pbc/traj.xyz
new file mode 100644
index 0000000000000000000000000000000000000000..88a0b60aa8788e8f5924ede8a1bc2bd597354d3d
--- /dev/null
+++ b/regtest/basic/rt-moving-restraint-pbc/traj.xyz
@@ -0,0 +1,60 @@
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
+4
+0 0 0
+X 1 0 1
+X 0 0 1
+X 0 0 -1
+X 0 1 -1
diff --git a/src/adjmat/AdjacencyMatrixBase.cpp b/src/adjmat/AdjacencyMatrixBase.cpp
index ab067b0cc7bd376685c1febffcf50aa0f2826723..4f9844f9bc36cc7190808f7bba8836df9028fc9f 100644
--- a/src/adjmat/AdjacencyMatrixBase.cpp
+++ b/src/adjmat/AdjacencyMatrixBase.cpp
@@ -149,8 +149,15 @@ void AdjacencyMatrixBase::retrieveTypeDimensions( unsigned& nrows, unsigned& nco
 void AdjacencyMatrixBase::finishMatrixSetup( const bool& symmetric, const std::vector<AtomNumber>& all_atoms ){
   std::string param;
   if( symmetric && ablocks[0].size()==ablocks[1].size() ) param="SYMMETRIC";
-  if( !symmetric && ablocks[0].size()==ablocks[1].size() ) param="HBONDS";
-
+  if( !symmetric ){
+      bool usehbonds=( ablocks[0].size()==ablocks[1].size() );
+      if( usehbonds ){
+          for(unsigned i=0;i<ablocks[0].size();++i){
+              if( ablocks[0][i]!=ablocks[1][i] ){ usehbonds = false; break; } 
+          } 
+          if( usehbonds ) param="HBONDS";       
+      } 
+  }
 
   vesselbase::VesselOptions da("","",0,param,this);
   Keywords keys; AdjacencyMatrixVessel::registerKeywords( keys );
diff --git a/src/bias/MovingRestraint.cpp b/src/bias/MovingRestraint.cpp
index 5de07d1078f0bed00a351c7adf1471b855d4382a..02c08fb4e9e4124501278582ac3d3ba0d5ef9182 100644
--- a/src/bias/MovingRestraint.cpp
+++ b/src/bias/MovingRestraint.cpp
@@ -230,7 +230,11 @@ void MovingRestraint::calculate(){
     double c2=(now-step[i-1])/double(step[i]-step[i-1]);
     double c1=1.0-c2;
     for(unsigned j=0;j<narg;j++) kk[j]=(c1*kappa[i-1][j]+c2*kappa[i][j]);
-    for(unsigned j=0;j<narg;j++) aa[j]=(c1*at[i-1][j]+c2*at[i][j]);
+    for(unsigned j=0;j<narg;j++) {
+      const double a1=at[i-1][j];
+      const double a2=at[i][j];
+      aa[j]=(c1*a1+c2*(a1+difference(j,a1,a2)));
+    }
   }
   tot_work=0.0;
   for(unsigned i=0;i<narg;++i){
diff --git a/src/function/FuncSumHills.cpp b/src/function/FuncSumHills.cpp
index 25ed19207d65c136961d338ee9d9c7b5ec26763f..5231b0fdc9e3411abed14766d234604bb234cb4a 100644
--- a/src/function/FuncSumHills.cpp
+++ b/src/function/FuncSumHills.cpp
@@ -26,6 +26,7 @@
 #include "tools/BiasRepresentation.h"
 #include "tools/File.h"
 #include "tools/Tools.h"
+#include "tools/Stopwatch.h"
 #include <iostream>
 
 using namespace std;
@@ -503,6 +504,10 @@ historep(NULL)
     if(integratehills)	hillsHandler=new FilesHandler(hillsFiles,parallelread,*this, log);
     if(integratehisto)	histoHandler=new FilesHandler(histoFiles,parallelread,*this, log);
 
+    Stopwatch sw;
+
+    sw.start("0 Summing hills");
+
     // read a number of hills and put in the bias representation
     int nfiles=0;
     bool ibias=integratehills; bool ihisto=integratehisto;
@@ -612,6 +617,10 @@ historep(NULL)
 	nfiles++;
     }
 
+    sw.stop("0 Summing hills");
+
+    log<<sw;
+
     return;
   } 
   // just an initialization but you need to do something on the fly?: need to connect with a metad run and its grid representation 
diff --git a/src/multicolvar/Distances.cpp b/src/multicolvar/Distances.cpp
index 0ff7ab6d1a0871de08ab578ecd26c5af709ba403..4ea6d867e9569d52941149b3c1cff3711ae5acf2 100644
--- a/src/multicolvar/Distances.cpp
+++ b/src/multicolvar/Distances.cpp
@@ -174,7 +174,7 @@ MultiColvarBase(ao)
          use_link=true; rcut=lt->getCutoff();
      } else {
          vesselbase::Between* bt=dynamic_cast<vesselbase::Between*>( getPntrToVessel(0) );
-         if( bt ) use_link=true; rcut=bt->getCutoff();
+         if( bt ){ use_link=true; rcut=bt->getCutoff(); }
      }
      if( use_link ){
          for(unsigned i=1;i<getNumberOfVessels();++i){
diff --git a/src/tools/IFile.cpp b/src/tools/IFile.cpp
index 6518eeb2463309c1a8b4bd380cafb49526a4fa12..c1334fb5cf2422242459a93dd41e6c7fbac727f4 100644
--- a/src/tools/IFile.cpp
+++ b/src/tools/IFile.cpp
@@ -28,6 +28,7 @@
 #include "Tools.h"
 #include <cstdarg>
 #include <cstring>
+#include <cmath>
 
 #include <iostream>
 #include <string>
@@ -162,7 +163,8 @@ IFile& IFile::scanField(const std::string&name,int &x){
 }
 
 IFile& IFile::scanField(Value* val){
-  double ff; scanField(  val->getName(), ff );
+  double ff=NAN; // this is to be sure a NAN value is replaced upon failure
+  scanField(  val->getName(), ff );
   val->set( ff );
   if( FieldExist("min_" + val->getName() ) ){ 
       std::string min, max;