diff --git a/boundaries/boundaryhandling.py b/boundaries/boundaryhandling.py
index 569a098ae2dc85f7d2973b0fc6814c2eccdb6d97..5897cd17c1b1c22001d85171b64ec66a1da4842a 100644
--- a/boundaries/boundaryhandling.py
+++ b/boundaries/boundaryhandling.py
@@ -12,7 +12,7 @@ class BoundaryHandling(PeriodicityHandling, GenericBoundaryHandling):  # importa
         flagInterface = NumpyFlagFieldInterface(shapeWithGl, flagDtype)
 
         GenericBoundaryHandling.__init__(self, flagInterface, pdfField, lbMethod, None, ghostLayers, target, openMP)
-        PeriodicityHandling.__init__(self, list(domainShape) + [len(lbMethod.stencil)])
+        PeriodicityHandling.__init__(self, list(domainShape) + [len(lbMethod.stencil)], target=target)
 
     def __call__(self, *args, **kwargs):
         for cls in BoundaryHandling.__bases__:
diff --git a/boundaries/periodicityhandling.py b/boundaries/periodicityhandling.py
index d5b86ed890bf1b0efe507e993218db3533c51c67..428afcaed04dd5917a8f927c040e1417ded958df 100644
--- a/boundaries/periodicityhandling.py
+++ b/boundaries/periodicityhandling.py
@@ -2,12 +2,13 @@ from lbmpy.stencils import getStencil
 
 
 class PeriodicityHandling(object):
-    def __init__(self, fieldShape, periodicity=(False, False, False)):
+    def __init__(self, fieldShape, periodicity=(False, False, False), target='cpu'):
         self._spatialShape = fieldShape[:-1]
         self._indexShape = fieldShape[-1]
         self._periodicity = list(periodicity)
-        self._periodicityDirty = False
+        self._periodicityDirty = True
         self._periodicityKernels = []
+        self._target = target
 
     @property
     def periodicity(self):
@@ -33,7 +34,7 @@ class PeriodicityHandling(object):
             return
 
         self._periodicityKernels = []
-        dim = len(self.flagField.shape)
+        dim = len(self._spatialShape)
         if dim == 2:
             stencil = getStencil("D2Q9")
         elif dim == 3: