diff --git a/cpu/cpujit.py b/cpu/cpujit.py
index 789d08a641a30e590995f1a9b67def34667ef76c..a0bccbc21d86acf4323b26a9ed7b83a3e92068b4 100644
--- a/cpu/cpujit.py
+++ b/cpu/cpujit.py
@@ -12,7 +12,7 @@ import hashlib
 from pystencils.transformations import symbolNameToVariableName
 
 CONFIG_GCC = {
-    'compiler': 'g++',
+    'compiler': 'g++-4.8',
     'flags': '-Ofast -DNDEBUG -fPIC -shared -march=native -fopenmp',
 }
 CONFIG_INTEL = {
diff --git a/cpu/kernelcreation.py b/cpu/kernelcreation.py
index b3340a39b3a3a9bfb80d4d8e8885a7db4240a66d..f5fb46569331c68256e017c4e4f30ffaed55c08a 100644
--- a/cpu/kernelcreation.py
+++ b/cpu/kernelcreation.py
@@ -43,7 +43,6 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl
 
     fieldsRead, fieldsWritten, assignments = typeAllEquations(listOfEquations, typeForSymbol)
     allFields = fieldsRead.union(fieldsWritten)
-
     readOnlyFields = set([f.name for f in fieldsRead - fieldsWritten])
 
     body = ast.Block(assignments)
diff --git a/gpucuda/cudajit.py b/gpucuda/cudajit.py
index 71c00832e008c7ca5c78b7cbe53cb6c38e285e4c..d7385eb1300ead22a18fbbca40d0fd72abaa6ba1 100644
--- a/gpucuda/cudajit.py
+++ b/gpucuda/cudajit.py
@@ -58,7 +58,7 @@ def buildNumpyArgumentList(kernelFunctionNode, argumentDict):
 
 
 def makePythonFunction(kernelFunctionNode, argumentDict={}):
-    mod = SourceModule(str(generateCUDA(kernelFunctionNode)))
+    mod = SourceModule(str(generateCUDA(kernelFunctionNode)), options=["-w"])
     func = mod.get_function(kernelFunctionNode.functionName)
 
     def wrapper(**kwargs):
diff --git a/gpucuda/kernelcreation.py b/gpucuda/kernelcreation.py
index 43118652efe822d7bfb4c7c22c7140a09315eb04..09d1efdf1c2a844840ace129bb4f55435bc4a8ec 100644
--- a/gpucuda/kernelcreation.py
+++ b/gpucuda/kernelcreation.py
@@ -25,7 +25,7 @@ def getLinewiseCoordinates(field, ghostLayers):
                 return arrShape[result.index(cudaIdx)] - 2 * ghostLayers
 
         return {'block': tuple([getShapeOfCudaIdx(idx) for idx in THREAD_IDX]),
-                'grid': tuple([getShapeOfCudaIdx(idx) for idx in BLOCK_IDX]) }
+                'grid': tuple([getShapeOfCudaIdx(idx) for idx in BLOCK_IDX])}
 
     return [i + ghostLayers for i in result], getCallParameters
 
@@ -37,18 +37,16 @@ def createCUDAKernel(listOfEquations, functionName="kernel", typeForSymbol=None)
         typeForSymbol = typingFromSympyInspection(listOfEquations, "float")
 
     fieldsRead, fieldsWritten, assignments = typeAllEquations(listOfEquations, typeForSymbol)
-    readOnlyFields = set([f.name for f in fieldsRead - fieldsWritten])
-
     allFields = fieldsRead.union(fieldsWritten)
+    readOnlyFields = set([f.name for f in fieldsRead - fieldsWritten])
 
-    code = KernelFunction(Block(assignments), fieldsRead.union(fieldsWritten), functionName)
+    code = KernelFunction(Block(assignments), allFields, functionName)
     code.globalVariables.update(BLOCK_IDX + THREAD_IDX)
 
     fieldAccesses = code.atoms(Field.Access)
     requiredGhostLayers = max([fa.requiredGhostLayers for fa in fieldAccesses])
 
     coordMapping, getCallParameters = getLinewiseCoordinates(list(fieldsRead)[0], requiredGhostLayers)
-    allFields = fieldsRead.union(fieldsWritten)
     basePointerInfo = [['spatialInner0']]
     basePointerInfos = {f.name: parseBasePointerInfo(basePointerInfo, [2, 1, 0], f) for f in allFields}
 
diff --git a/slicing.py b/slicing.py
index ad792f6f4c4a745a9ed184d691840c164e87d913..7eebb38eaa3709a5f01b68e48e4d8129f5de881f 100644
--- a/slicing.py
+++ b/slicing.py
@@ -1,4 +1,5 @@
 import sympy as sp
+import numpy as np
 
 
 class SliceMaker(object):
@@ -78,3 +79,22 @@ def sliceFromDirection(directionName, dim, normalOffset=0, tangentialOffset=0):
             assert lowName not in directionName, "Invalid direction name"
             result[dimIdx] = normalSliceHigh
     return tuple(result)
+
+
+def removeGhostLayers(arr, indexDimensions=0, ghostLayers=1):
+    dimensions = len(arr.shape)
+    spatialDimensions = dimensions - indexDimensions
+    indexing = [slice(ghostLayers, -ghostLayers, None), ] * spatialDimensions
+    indexing += [slice(None, None, None)] * indexDimensions
+    return arr[indexing]
+
+
+def addGhostLayers(arr, indexDimensions=0, ghostLayers=1):
+    dimensions = len(arr.shape)
+    spatialDimensions = dimensions - indexDimensions
+    newShape = [e + 2 * ghostLayers for e in arr.shape[:spatialDimensions]] + list(arr.shape[spatialDimensions:])
+    result = np.zeros(newShape)
+    indexing = [slice(ghostLayers, -ghostLayers, None), ] * spatialDimensions
+    indexing += [slice(None, None, None)] * indexDimensions
+    result[indexing] = arr
+    return result