diff --git a/patches/gromacs-2019.2.config b/patches/gromacs-2019.4.config
similarity index 100%
rename from patches/gromacs-2019.2.config
rename to patches/gromacs-2019.4.config
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/CMakeLists.txt b/patches/gromacs-2019.4.diff/src/gromacs/CMakeLists.txt
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/CMakeLists.txt
rename to patches/gromacs-2019.4.diff/src/gromacs/CMakeLists.txt
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/CMakeLists.txt.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/CMakeLists.txt.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/CMakeLists.txt.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/CMakeLists.txt.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdlib/force.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdlib/force.cpp
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdlib/force.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdlib/force.cpp
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdlib/force.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdlib/force.cpp.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdlib/force.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdlib/force.cpp.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.cpp
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.cpp
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.h b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.h
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.h
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.h
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp
similarity index 98%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp
index 887526a8d1dff7bdb05905ed784c1e500086501c..0c649e918a87847f7a0d13b12e4c30aafa38b247 100644
--- a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp
+++ b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -792,6 +792,11 @@ void gmx::Integrator::do_md()
         /* Determine whether or not to do Neighbour Searching */
         bNS = (bFirstStep || bNStList || bExchanged || bNeedRepartition);
 
+        /* Note that the stopHandler will cause termination at nstglobalcomm
+         * steps. Since this concides with nstcalcenergy, nsttcouple and/or
+         * nstpcouple steps, we have computed the half-step kinetic energy
+         * of the previous step and can always output energies at the last step.
+         */
         bLastStep = bLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
 
         /* do_log triggers energy and virial calculation. Because this leads
@@ -1442,9 +1447,16 @@ void gmx::Integrator::do_md()
         {
             // Organize to do inter-simulation signalling on steps if
             // and when algorithms require it.
-            bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
+            const bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
+
+            // With leap-frog we also need to compute the half-step
+            // kinetic energy at the step before we need to write
+            // the full-step kinetic energy
+            const bool needEkinAtNextStep =
+                (!EI_VV(ir->eI) && (do_per_step(step + 1, nstglobalcomm) ||
+                                    step_rel + 1 == ir->nsteps));
 
-            if (bGStat || (!EI_VV(ir->eI) && do_per_step(step+1, nstglobalcomm)) || doInterSimSignal)
+            if (bGStat || needEkinAtNextStep || doInterSimSignal)
             {
                 // Since we're already communicating at this step, we
                 // can propagate intra-simulation signals. Note that
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp.preplumed
similarity index 98%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp.preplumed
index a49a15df53a4246970f4f4a00e542f1c9a7cedbe..f0a634fc61d39370094fcd95e95ffcebd208d569 100644
--- a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/md.cpp.preplumed
+++ b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/md.cpp.preplumed
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -729,6 +729,11 @@ void gmx::Integrator::do_md()
         /* Determine whether or not to do Neighbour Searching */
         bNS = (bFirstStep || bNStList || bExchanged || bNeedRepartition);
 
+        /* Note that the stopHandler will cause termination at nstglobalcomm
+         * steps. Since this concides with nstcalcenergy, nsttcouple and/or
+         * nstpcouple steps, we have computed the half-step kinetic energy
+         * of the previous step and can always output energies at the last step.
+         */
         bLastStep = bLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
 
         /* do_log triggers energy and virial calculation. Because this leads
@@ -1245,9 +1250,16 @@ void gmx::Integrator::do_md()
         {
             // Organize to do inter-simulation signalling on steps if
             // and when algorithms require it.
-            bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
+            const bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
+
+            // With leap-frog we also need to compute the half-step
+            // kinetic energy at the step before we need to write
+            // the full-step kinetic energy
+            const bool needEkinAtNextStep =
+                (!EI_VV(ir->eI) && (do_per_step(step + 1, nstglobalcomm) ||
+                                    step_rel + 1 == ir->nsteps));
 
-            if (bGStat || (!EI_VV(ir->eI) && do_per_step(step+1, nstglobalcomm)) || doInterSimSignal)
+            if (bGStat || needEkinAtNextStep || doInterSimSignal)
             {
                 // Since we're already communicating at this step, we
                 // can propagate intra-simulation signals. Note that
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp
similarity index 99%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp
index 6fb913acdf7fda216bd50c6a63cb04f973064344..f4d0d562f9e2a98b9f104311ab8b6a17142d5c78 100644
--- a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp
+++ b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp
@@ -2688,8 +2688,15 @@ Integrator::do_steep()
             }
         }
 
-        /* Determine new step  */
-        stepsize = ustep/s_min->fmax;
+        // If the force is very small after finishing minimization,
+        // we risk dividing by zero when calculating the step size.
+        // So we check first if the minimization has stopped before
+        // trying to obtain a new step size.
+        if (!bDone)
+        {
+            /* Determine new step  */
+            stepsize = ustep/s_min->fmax;
+        }
 
         /* Check if stepsize is too small, with 1 nm as a characteristic length */
 #if GMX_DOUBLE
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp.preplumed
similarity index 99%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp.preplumed
index 77421a32af2150f87ad728007fa66bd100d3a98c..427ec544461876fb6febde42c470826f4477261e 100644
--- a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/minimize.cpp.preplumed
+++ b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/minimize.cpp.preplumed
@@ -2613,8 +2613,15 @@ Integrator::do_steep()
             }
         }
 
-        /* Determine new step  */
-        stepsize = ustep/s_min->fmax;
+        // If the force is very small after finishing minimization,
+        // we risk dividing by zero when calculating the step size.
+        // So we check first if the minimization has stopped before
+        // trying to obtain a new step size.
+        if (!bDone)
+        {
+            /* Determine new step  */
+            stepsize = ustep/s_min->fmax;
+        }
 
         /* Check if stepsize is too small, with 1 nm as a characteristic length */
 #if GMX_DOUBLE
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.cpp
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.cpp
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.h b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.h
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.h
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.h
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.h.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.h.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/replicaexchange.h.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/replicaexchange.h.preplumed
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/runner.cpp b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/runner.cpp
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/runner.cpp
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/runner.cpp
diff --git a/patches/gromacs-2019.2.diff/src/gromacs/mdrun/runner.cpp.preplumed b/patches/gromacs-2019.4.diff/src/gromacs/mdrun/runner.cpp.preplumed
similarity index 100%
rename from patches/gromacs-2019.2.diff/src/gromacs/mdrun/runner.cpp.preplumed
rename to patches/gromacs-2019.4.diff/src/gromacs/mdrun/runner.cpp.preplumed