diff --git a/src/analysis/Histogram.cpp b/src/analysis/Histogram.cpp
index a2c9c7e23f92c252548883e700d54879106f4a29..cee0a87e34f3e09464c335478f69dbd4e3f4afea 100644
--- a/src/analysis/Histogram.cpp
+++ b/src/analysis/Histogram.cpp
@@ -298,7 +298,7 @@ void Histogram::prepareForAveraging(){
           lockContributors();
       } else {
           // This is used when we are not doing kernel density evaluation
-          mygrid->setGridElement( neighbors[0], 0, mygrid->getGridElement( neighbors[0], 0 ) + cweight ); 
+          mygrid->addToGridElement( neighbors[0], 0, cweight );
       }  
   }
 }
diff --git a/src/gridtools/GridVessel.cpp b/src/gridtools/GridVessel.cpp
index 55def546ff73929f527c79f8f2eddc17e204f4f6..82a6a6ce68bf72c9f0b7099bbc75cff1342988af 100644
--- a/src/gridtools/GridVessel.cpp
+++ b/src/gridtools/GridVessel.cpp
@@ -201,6 +201,11 @@ void GridVessel::setGridElement( const unsigned& ipoint, const unsigned& jelemen
   setDataElement( nper*ipoint + jelement, value );
 }
 
+void GridVessel::addToGridElement( const unsigned& ipoint, const unsigned& jelement, const double& value ){
+  plumed_dbg_assert( bounds_set && ipoint<npoints && jelement<nper );
+  addDataElement( nper*ipoint + jelement, value );
+} 
+
 void GridVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
   plumed_dbg_assert( myvals.getNumberOfValues()==(nper+1) );
   for(unsigned i=0;i<nper;++i) buffer[bufstart + nper*current + i] += myvals.get(i+1);
diff --git a/src/gridtools/GridVessel.h b/src/gridtools/GridVessel.h
index a0aacf47c6090866749bdac0d5d4eb14db760450..6fdf49b732ea3f515bf20c8887f3937062612faa 100644
--- a/src/gridtools/GridVessel.h
+++ b/src/gridtools/GridVessel.h
@@ -89,10 +89,10 @@ public:
  void getIndices( const unsigned& index, std::vector<unsigned>& indices ) const ;
 /// Get the indices of a particular point
  void getIndices( const std::vector<double>& point, std::vector<unsigned>& indices ) const ;
-
 /// Operations on one of the elements of grid point i
  void setGridElement( const unsigned&, const unsigned&, const double& );
-
+/// Add data to an element of the grid
+ void addToGridElement( const unsigned& ipoint, const unsigned& jelement, const double& value );
 /// Operations on one of the elements of grid point specified by vector
  double getGridElement( const std::vector<unsigned>&, const unsigned& ) const ;
  void setGridElement( const std::vector<unsigned>&, const unsigned&, const double& );
diff --git a/src/gridtools/HistogramOnGrid.cpp b/src/gridtools/HistogramOnGrid.cpp
index b227ef6937502ac810709a61980824d64ab7e0e5..50962b9168d6bc8bae549874b724bd5ed01750b7 100644
--- a/src/gridtools/HistogramOnGrid.cpp
+++ b/src/gridtools/HistogramOnGrid.cpp
@@ -102,7 +102,7 @@ void HistogramOnGrid::calculate( const unsigned& current, MultiValue& myvals, st
      KernelFunctions* kernel=getKernelAndNeighbors( point, num_neigh, neighbors );
 
      if( !kernel ){
-         plumed_dbg_assert( num_neigh==1 );
+         plumed_dbg_assert( num_neigh==1 ); der.resize(0);
          accumulate( neighbors[0], weight, 1.0, der, buffer );
      } else {
          std::vector<Value*> vv( getVectorOfValues() );