diff --git a/pub/CHANGELOG b/pub/CHANGELOG
index 00a0bf0c7236877d7edfba148860db261c42241e..52d8b59b0c701621bb06abe1558a04721fbd67d9 100644
--- a/pub/CHANGELOG
+++ b/pub/CHANGELOG
@@ -1,3 +1,5 @@
+- Code cleanup: decoupled plot window administration from the actual plotting
+
 Release 2.3.6c of 17mar17:
 
 - New command dv to display list of defined variables
diff --git a/pub/plot/ps_plotter.cpp b/pub/plot/ps_plotter.cpp
index 9afa90702e48f5c22ca440b5f95c2355b11eb6ae..90395470e41199d2767da15bac4451dce48edb79 100644
--- a/pub/plot/ps_plotter.cpp
+++ b/pub/plot/ps_plotter.cpp
@@ -34,8 +34,9 @@ void CPS_Plotter::plot_frame(
     X = &_X;
     Y = &_Y;
 
-    ps_accu += str(format("\n%i %g %g xSetCoord\n") % X->logflag % X->inf % X->sup);
-    ps_accu += str(format("\n%i %g %g ySetCoord\n") % Y->logflag % Y->inf % Y->sup);
+    ps_accu += "\n";
+    ps_accu += str(format("%1i %g %g xSetCoord\n") % X->logflag % X->inf % X->sup);
+    ps_accu += str(format("%1i %g %g ySetCoord\n") % Y->logflag % Y->inf % Y->sup);
 
     int ntpt;
     double ticklim[2];
@@ -63,7 +64,8 @@ void CPS_Plotter::plot_frame(
         "   0 10   0  0    90   0 OneAxx Axx Tic Tac yNumL %% left y axis\n"
         "   0 10  10  0    90 180 OneAxx Axx Tic Tac       %% right y axis\n"
         "  yCL\n"
-        "} def\n\n";
+        "} def\n\n"
+        "plotbefore\n\n";
 }
 
 void CPS_Plotter::add_spec(