diff --git a/src/core/mpi/MPIWrapper.h b/src/core/mpi/MPIWrapper.h
index f97cb06b197565e4fdbb15f8e1983a614053e250..112e59d9fe282121ca508a4bb209724ef6c38e91 100644
--- a/src/core/mpi/MPIWrapper.h
+++ b/src/core/mpi/MPIWrapper.h
@@ -107,6 +107,7 @@ struct MPI_Status
    int MPI_ERROR;
 };
 
+typedef void (MPI_User_function) (void * a, void * b, int * len, MPI_Datatype * );
 
 
 const int MPI_COMM_NULL  = 0;
@@ -265,6 +266,11 @@ inline int MPI_Error_string ( int, char*, int* ) { WALBERLA_MPI_FUNCTION_ERROR }
 
 inline double MPI_Wtime() { WALBERLA_MPI_FUNCTION_ERROR }
 
+inline int MPI_Op_create(MPI_User_function*, int, MPI_Op*) { WALBERLA_MPI_FUNCTION_ERROR };
+inline int MPI_Type_create_struct(int, const int[], MPI_Aint[], MPI_Datatype[], MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
+inline int MPI_Type_create_resized(MPI_Datatype, MPI_Aint, MPI_Aint, MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
+int MPI_Type_commit(MPI_Datatype*) { WALBERLA_MPI_FUNCTION_ERROR };
+
 #undef WALBERLA_MPI_FUNCTION_ERROR
 
 } // namespace mpistubs
diff --git a/src/pe/raytracing/Raytracer.cpp b/src/pe/raytracing/Raytracer.cpp
index fb3ce40c510dad48956dfaf0fd9118c7addad9b3..eceba32b64d2fe30bb41207d4a9c9ff48ca51ad6 100644
--- a/src/pe/raytracing/Raytracer.cpp
+++ b/src/pe/raytracing/Raytracer.cpp
@@ -20,12 +20,12 @@
 
 #include "Raytracer.h"
 #include "geometry/structured/extern/lodepng.h"
+#include "core/mpi/all.h"
 
 namespace walberla {
 namespace pe {
 namespace raytracing {
    
-#ifdef WALBERLA_BUILD_WITH_MPI
 void BodyIntersectionInfo_Comparator_MPI_OP( BodyIntersectionInfo *in, BodyIntersectionInfo *inout, int *len, MPI_Datatype *dptr) {
    WALBERLA_UNUSED(dptr);
    for (int i = 0; i < *len; ++i) {
@@ -48,7 +48,6 @@ void BodyIntersectionInfo_Comparator_MPI_OP( BodyIntersectionInfo *in, BodyInter
       inout++;
    }
 }
-#endif
 
 /*!\brief Instantiation constructor for the Raytracer class.
  *
@@ -100,7 +99,9 @@ Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, const BlockDataID st
    
    setupView_();
    setupFilenameRankWidth_();
-   setupMPI_();
+   WALBERLA_MPI_SECTION() {
+      setupMPI_();
+   }
 }
 
 /*!\brief Instantiation constructor for the Raytracer class using a config object for view setup.
@@ -181,7 +182,9 @@ Raytracer::Raytracer(const shared_ptr<BlockStorage> forest, const BlockDataID st
       
    setupView_();
    setupFilenameRankWidth_();
-   setupMPI_();
+   WALBERLA_MPI_SECTION() {
+      setupMPI_();
+   }
 }
 
 /*!\brief Utility function for setting up the view plane and calculating required variables.
@@ -207,16 +210,13 @@ void Raytracer::setupView_() {
 /*!\brief Utility function for initializing the attribute filenameRankWidth.
  */
 void Raytracer::setupFilenameRankWidth_() {
-   WALBERLA_MPI_SECTION() {
-      int numProcesses = mpi::MPIManager::instance()->numProcesses();
-      filenameRankWidth_ = uint8_c(log10(numProcesses)+1);
-   }
+   int numProcesses = mpi::MPIManager::instance()->numProcesses();
+   filenameRankWidth_ = uint8_c(log10(numProcesses)+1);
 }
 
 /*!\brief Utility function for setting up the MPI datatype and operation.
  */
 void Raytracer::setupMPI_() {
-#ifdef WALBERLA_BUILD_WITH_MPI
    MPI_Op_create((MPI_User_function *)BodyIntersectionInfo_Comparator_MPI_OP, true, &bodyIntersectionInfo_reduction_op);
    
    const int nblocks = 7;
@@ -247,7 +247,6 @@ void Raytracer::setupMPI_() {
    MPI_Type_create_resized( tmp_type, lb, extent, &bodyIntersectionInfo_mpi_type );
    
    MPI_Type_commit(&bodyIntersectionInfo_mpi_type);
-#endif
 }
    
 /*!\brief Generates the filename for output files.
@@ -338,7 +337,12 @@ void Raytracer::writeImageToFile(const std::vector<BodyIntersectionInfo>& inters
  * \attention This function only works on MPI builds due to the explicit usage of MPI routines.
  */
 void Raytracer::syncImageUsingMPIReduce(std::vector<BodyIntersectionInfo>& intersectionsBuffer, WcTimingTree* tt) {
-#ifdef WALBERLA_BUILD_WITH_MPI
+   WALBERLA_NON_MPI_SECTION() {
+      WALBERLA_UNUSED(intersectionsBuffer);
+      WALBERLA_UNUSED(tt);
+      WALBERLA_ABORT("Cannot call MPI reduce on a non-MPI build due to usage of MPI-specific code.");
+   }
+   
    WALBERLA_MPI_BARRIER();
    if (tt != NULL) tt->start("Reduction");
    int rank = mpi::MPIManager::instance()->rank();
@@ -357,11 +361,6 @@ void Raytracer::syncImageUsingMPIReduce(std::vector<BodyIntersectionInfo>& inter
    
    WALBERLA_MPI_BARRIER();
    if (tt != NULL) tt->stop("Reduction");
-#else
-   WALBERLA_UNUSED(intersectionsBuffer);
-   WALBERLA_UNUSED(tt);
-   WALBERLA_ABORT("Cannot call MPI reduce on a non-MPI build due to usage of MPI-specific code.");
-#endif
 }
   
 /*!\brief Conflate the intersectionsBuffer of each process onto the root process using MPI_Gather.
diff --git a/src/pe/raytracing/Raytracer.h b/src/pe/raytracing/Raytracer.h
index 5c56256a5ad36deb787cd87546cfede44634c443..4d64a371f3e6eae4b61c93c8adaf434f2720cc66 100644
--- a/src/pe/raytracing/Raytracer.h
+++ b/src/pe/raytracing/Raytracer.h
@@ -35,9 +35,6 @@
 #include "pe/ccd/ICCD.h"
 #include <pe/ccd/HashGrids.h>
 
-#include "core/mpi/MPIManager.h"
-#include "core/mpi/MPIWrapper.h"
-#include "core/mpi/all.h"
 #include <stddef.h>
 
 using namespace walberla::pe;
@@ -156,10 +153,8 @@ private:
    real_t pixelHeight_;       //!< The height of a pixel of the generated image in the viewing plane.
    //@}
    
-#ifdef WALBERLA_BUILD_WITH_MPI
    MPI_Op bodyIntersectionInfo_reduction_op;
    MPI_Datatype bodyIntersectionInfo_mpi_type;
-#endif
    
 public:
    /*!\name Get functions */
@@ -647,8 +642,7 @@ void Raytracer::generateImage(const size_t timestep, WcTimingTree* tt) {
             syncImageUsingMPIGather(intersections, intersectionsBuffer, tt);
             break;
       }
-   }
-   WALBERLA_NON_MPI_SECTION() {
+   } else {
       syncImageUsingMPIGather(intersections, intersectionsBuffer, tt);
    }
    
diff --git a/tests/pe/Raytracing.cpp b/tests/pe/Raytracing.cpp
index 5b450b9d152616fdefe4512eb75574c0cc9959e3..b3910f5501ae4a0695714fc4075c6500cb8a334d 100644
--- a/tests/pe/Raytracing.cpp
+++ b/tests/pe/Raytracing.cpp
@@ -352,7 +352,6 @@ void RaytracerSpheresTestScene(Raytracer::Algorithm raytracingAlgorithm = Raytra
                        Vec3(-5,5,5), Vec3(-1,5,5), Vec3(0,0,1), //-5,5,5; -1,5,5
                        lighting,
                        Color(real_t(0.2),real_t(0.2),real_t(0.2)),
-                       real_t(2),
                        customSpheresBodyToShadingParams);
    
    MaterialID iron = Material::find("iron");
@@ -535,7 +534,6 @@ void HashGridsTest(Raytracer::Algorithm raytracingAlgorithm, uint8_t antiAliasFa
                            std::get<2>(vector),
                            lighting0,
                            Color(real_t(0.2),real_t(0.2),real_t(0.2)),
-                           real_t(2),
                            customHashGridsBodyToShadingParams);
       raytracer.setImageOutputEnabled(true);
       raytracer.setFilenameTimestepWidth(12);
@@ -579,7 +577,6 @@ void raytraceArtifactsForest(Raytracer::Algorithm raytracingAlgorithm, uint8_t a
                        upVector,
                        lighting,
                        Color(real_t(0.2),real_t(0.2),real_t(0.2)),
-                       real_t(2),
                        customArtifactsBodyToShadingParams);
    raytracer.setImageOutputEnabled(true);
    raytracer.setFilenameTimestepWidth(timestepWidth);
@@ -818,8 +815,7 @@ void HashGridsTestScene(Raytracer::Algorithm raytracingAlgorithm = Raytracer::RA
                           std::get<1>(vector),
                           std::get<2>(vector),
                           lighting,
-                          Color(real_t(0.2),real_t(0.2),real_t(0.2)),
-                          real_t(2));
+                          Color(real_t(0.2),real_t(0.2),real_t(0.2)));
       
       raytracer.setRaytracingAlgorithm(raytracingAlgorithm);
       raytracer.setImageOutputEnabled(true);
@@ -855,6 +851,7 @@ int main( int argc, char** argv )
    RaytracerTest(algorithm, antiAliasFactor);
    //RaytracerSpheresTestScene(algorithm, antiAliasFactor);
    HashGridsTestScene(algorithm, antiAliasFactor);
+   
    HashGridsTest(algorithm, antiAliasFactor,
                  50, 30, 130,
                  10);