diff --git a/pystencils_walberla/templates/GpuPackInfo.tmpl.h b/pystencils_walberla/templates/GpuPackInfo.tmpl.h
index 74bd12b1f66a4b6284dfaf1f1088e2f12bbb1c06..19d68f5e55ff4c3422eb4ca47abad1d340257ce1 100644
--- a/pystencils_walberla/templates/GpuPackInfo.tmpl.h
+++ b/pystencils_walberla/templates/GpuPackInfo.tmpl.h
@@ -1,3 +1,4 @@
+#pragma once
 #include "stencil/Directions.h"
 #include "core/cell/CellInterval.h"
 #include "cuda/GPUField.h"
diff --git a/pystencils_walberla/templates/SweepInnerOuter.tmpl.cpp b/pystencils_walberla/templates/SweepInnerOuter.tmpl.cpp
index 3cf5069cd0980acdf2bc77dc1521d3cfe0d19c47..de1c5b58f5c1388c1e9997a1e7777624f3ca237a 100644
--- a/pystencils_walberla/templates/SweepInnerOuter.tmpl.cpp
+++ b/pystencils_walberla/templates/SweepInnerOuter.tmpl.cpp
@@ -85,38 +85,36 @@ void {{class_name}}::inner( IBlock * block{%if target is equalto 'gpu'%} , cudaS
 
 void {{class_name}}::outer( IBlock * block{%if target is equalto 'gpu'%} , cudaStream_t stream {% endif %} )
 {
-    static std::vector<CellInterval> layers;
-
     {{kernel|generate_block_data_to_field_extraction|indent(4)}}
 
-    if( layers.size() == 0 )
+    if( layers_.size() == 0 )
     {
         CellInterval ci;
 
         {{field}}->getSliceBeforeGhostLayer(stencil::T, ci, 1, false);
-        layers.push_back(ci);
+        layers_.push_back(ci);
         {{field}}->getSliceBeforeGhostLayer(stencil::B, ci, 1, false);
-        layers.push_back(ci);
+        layers_.push_back(ci);
 
         {{field}}->getSliceBeforeGhostLayer(stencil::N, ci, 1, false);
         ci.expand(Cell(0, 0, -1));
-        layers.push_back(ci);
+        layers_.push_back(ci);
         {{field}}->getSliceBeforeGhostLayer(stencil::S, ci, 1, false);
         ci.expand(Cell(0, 0, -1));
-        layers.push_back(ci);
+        layers_.push_back(ci);
 
         {{field}}->getSliceBeforeGhostLayer(stencil::E, ci, 1, false);
         ci.expand(Cell(0, -1, -1));
-        layers.push_back(ci);
+        layers_.push_back(ci);
         {{field}}->getSliceBeforeGhostLayer(stencil::W, ci, 1, false);
         ci.expand(Cell(0, -1, -1));
-        layers.push_back(ci);
+        layers_.push_back(ci);
     }
 
     {%if target is equalto 'gpu'%}
     {
         auto parallelSection_ = parallelStreams_.parallelSection( stream );
-        for( auto & ci: layers )
+        for( auto & ci: layers_ )
         {
             parallelSection_.run([&]( auto s ) {
                 {{kernel|generate_call(stream='s', cell_interval='ci')|indent(16)}}
@@ -124,7 +122,7 @@ void {{class_name}}::outer( IBlock * block{%if target is equalto 'gpu'%} , cudaS
         }
     }
     {% else %}
-    for( auto & ci: layers )
+    for( auto & ci: layers_ )
     {
         {{kernel|generate_call(cell_interval='ci')|indent(8)}}
     }
diff --git a/pystencils_walberla/templates/SweepInnerOuter.tmpl.h b/pystencils_walberla/templates/SweepInnerOuter.tmpl.h
index 733083a56e6d10008f605c37ed9eb96eddabf97e..c2c1d4d9c5c651c5f651fc15102a5656b50e3b5b 100644
--- a/pystencils_walberla/templates/SweepInnerOuter.tmpl.h
+++ b/pystencils_walberla/templates/SweepInnerOuter.tmpl.h
@@ -97,6 +97,8 @@ private:
     {%if target is equalto 'gpu'%}
     cuda::ParallelStreams parallelStreams_;
     {% endif %}
+
+    std::vector<CellInterval> layers_;
 };