diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8b7f434d2b086298c3400cc25fe5d52dbde59c0e..cd9bd6aa610d626e3273d496d4ba339790440b10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,7 +70,7 @@ endif()
 
 # Include aocommon/eigen3/pybind11 headers
 include_directories("${CMAKE_SOURCE_DIR}/external/aocommon/include/")
-include_directories("${CMAKE_SOURCE_DIR}/external/eigen/")
+include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/external/eigen/")
 # Find python with cmake to convince pybind11 to use right python path
 # This can go when we're using CMake >= 3.12:
 # https://pybind11.readthedocs.io/en/stable/compiling.html#findpython-mode
@@ -98,7 +98,7 @@ find_package(Threads REQUIRED)
 # Find and include Casacore
 set(CASACORE_MAKE_REQUIRED_EXTERNALS_OPTIONAL TRUE)
 find_package(Casacore REQUIRED COMPONENTS casa ms tables measures fits)
-include_directories(${CASACORE_INCLUDE_DIRS})
+include_directories(SYSTEM ${CASACORE_INCLUDE_DIRS})
 
 # Find and include Boost headers (boost::math required for MWA beam)
 find_package(Boost REQUIRED)
@@ -136,7 +136,17 @@ endif()
 set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED YES)
 set(CMAKE_CXX_EXTENSIONS NO)
-add_compile_options("${OpenMP_CXX_FLAGS}" -Wall)
+add_compile_options(
+  "${OpenMP_CXX_FLAGS}"
+  -Wall
+  -Wnon-virtual-dtor
+  -Wzero-as-null-pointer-constant
+  -Wduplicated-branches
+  -Wundef
+  -Wvla
+  -Wpointer-arith
+  -Wextra
+  -Wno-unused-parameter)
 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--no-undefined")
 
 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
diff --git a/demo/beam-helper.cpp b/demo/beam-helper.cpp
index 49e9e53c2f8497814d9db347670c1121dff08b27..14dbfe5d8fcb603a1d8154bb3826ffc4279bca11 100644
--- a/demo/beam-helper.cpp
+++ b/demo/beam-helper.cpp
@@ -150,16 +150,13 @@ void StoreBeam(const std::string& filename, const std::complex<float>* buffer,
             << " x " << ny << ")\n";
   std::vector<double> img(nx * ny * width * height, 0.0);
   for (size_t ant = 0; ant != nStations; ++ant) {
-    typedef std::complex<float> Data[nStations][height][width][4];
-    Data* data_ptr = (Data*)buffer;
-
     size_t xCorner = (ant % nx) * width, yCorner = (ant / nx) * height;
     for (size_t y = 0; y != height; ++y) {
       for (size_t x = 0; x != width; ++x) {
         std::complex<float> response = 0;
         for (auto pol = 0; pol < 4; pol++) {
-          std::complex<float> value = (*data_ptr)[ant][y][x][pol];
-          response += value * std::conj(value);
+          response += *buffer * std::conj(*buffer);
+          ++buffer;
         }
         img[(yCorner + y) * width * nx + x + xCorner] = abs(response) / 2;
       }
@@ -203,4 +200,4 @@ unsigned int GetNrAntennas(casacore::MeasurementSet& ms,
                                                   "m");
   casacore::Matrix<casacore::Quantity> aips_offset = offsetColumn(field_id);
   return aips_offset.ncolumn();
-}
\ No newline at end of file
+}