diff --git a/runtime/domain/block_forest.cpp b/runtime/domain/block_forest.cpp
index 61b7818b81b01977ea7c9dfec57a294bb6ae799f..44d30197437bef211a450f6e6ebfc59d0ff0e04d 100644
--- a/runtime/domain/block_forest.cpp
+++ b/runtime/domain/block_forest.cpp
@@ -27,6 +27,7 @@ void BlockForest::updateNeighborhood() {
 
     ranks.clear();
     naabbs.clear();
+    aabb_offsets.clear();
     aabbs.clear();
 
     for(auto& iblock: *forest) {
@@ -59,6 +60,7 @@ void BlockForest::updateNeighborhood() {
         auto rank = nbh.first;
         auto aabb_list = nbh.second;
         ranks.push_back((int) rank);
+        aabb_offsets.push_back(this->total_aabbs);
         naabbs.push_back((int) aabb_list.size());
 
         for(auto &aabb: aabb_list) {
@@ -80,7 +82,7 @@ void BlockForest::updateNeighborhood() {
 void BlockForest::copyRuntimeArray(const std::string& name, void *dest, const int size) {
     void *src = name.compare('ranks') ? ranks.data() :
                 name.compare('naabbs') ? vec_naabbs.data() :
-                name.compare('rank_offsets') ? offsets :
+                name.compare('aabb_offsets') ? aabb_offsets.data() :
                 name.compare('aabbs') ? vec_aabbs.data() :
                 name.compare('subdom') ? subdom;
 
@@ -102,7 +104,7 @@ void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) {
             ps, aabb.xMin(), aabb.xMax(), aabb.yMin(), aabb.yMax(), aabb.zMin(), aabb.zMax(),
             &(block_info.computationalWeight), &(block_info.communicationWeight));
 
-        for(uint_t branch = 0; branch < 8; ++branch) {
+        for(int branch = 0; branch < 8; ++branch) {
             const auto b_id = BlockID(block->getId(), branch);
             const auto b_aabb = forest->getAABBFromBlockId(b_id);
             auto& b_info = info[b_id];
@@ -117,16 +119,16 @@ void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) {
         auto block = static_cast<blockforest::Block *>(&iblock);
         auto& block_info = info[block->getId()];
 
-        for(uint_t neigh = 0; neigh < block->getNeighborhoodSize(); ++neigh) {
+        for(int neigh = 0; neigh < block->getNeighborhoodSize(); ++neigh) {
             bs.sendBuffer(block->getNeighborProcess(neigh)) <<
                 blockforest::InfoCollection::value_type(block->getId(), block_info);
         }
 
-        for(uint_t branch = 0; branch < 8; ++branch) {
+        for(int branch = 0; branch < 8; ++branch) {
             const auto b_id = BlockID(block->getId(), branch);
             auto& b_info = info[b_id];
 
-            for(uint_t neigh = 0; neigh < block->getNeighborhoodSize(); ++neigh) {
+            for(int neigh = 0; neigh < block->getNeighborhoodSize(); ++neigh) {
                 bs.sendBuffer(block->getNeighborProcess(neigh)) <<
                     blockforest::InfoCollection::value_type(b_id, b_info);
             }
@@ -145,27 +147,27 @@ void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) {
     }
 }
 
-Vector3<uint_t> BlockForest::getBlockConfig(uint_t num_processes, uint_t nx, uint_t ny, uint_t nz) {
-    const uint_t bx_factor = 1;
-    const uint_t by_factor = 1;
-    const uint_t bz_factor = 1;
-    const uint_t ax = nx * ny;
-    const uint_t ay = nx * nz;
-    const uint_t az = ny * nz;
+Vector3<int> BlockForest::getBlockConfig(int num_processes, int nx, int ny, int nz) {
+    const int bx_factor = 1;
+    const int by_factor = 1;
+    const int bz_factor = 1;
+    const int ax = nx * ny;
+    const int ay = nx * nz;
+    const int az = ny * nz;
 
-    uint_t bestsurf = 2 * (ax + ay + az);
-    uint_t x = 1;
-    uint_t y = 1;
-    uint_t z = 1;
+    int bestsurf = 2 * (ax + ay + az);
+    int x = 1;
+    int y = 1;
+    int z = 1;
 
-    for(uint_t i = 1; i < num_processes; ++i) {
+    for(int i = 1; i < num_processes; ++i) {
         if(num_processes % i == 0) {
-            const uint_t rem_yz = num_processes / i;
+            const int rem_yz = num_processes / i;
 
-            for(uint_t j = 1; j < rem_yz; ++j) {
+            for(int j = 1; j < rem_yz; ++j) {
                 if(rem_yz % j == 0) {
-                    const uint_t k = rem_yz / j;
-                    const uint_t surf = (ax / i / j) + (ay / i / k) + (az / j / k);
+                    const int k = rem_yz / j;
+                    const int surf = (ax / i / j) + (ay / i / k) + (az / j / k);
 
                     if(surf < bestsurf) {
                         x = i, y = j, z = k;
@@ -176,13 +178,13 @@ Vector3<uint_t> BlockForest::getBlockConfig(uint_t num_processes, uint_t nx, uin
         }
     }
 
-    return Vector3<uint_t>(x * bx_factor, y * by_factor, z * bz_factor);
+    return Vector3<int>(x * bx_factor, y * by_factor, z * bz_factor);
 }
 
-uint_t BlockForest::getInitialRefinementLevel(uint_t num_processes) {
-    uint_t splitFactor = 8;
-    uint_t blocks = splitFactor;
-    uint_t refinementLevel = 1;
+int BlockForest::getInitialRefinementLevel(int num_processes) {
+    int splitFactor = 8;
+    int blocks = splitFactor;
+    int refinementLevel = 1;
 
     while(blocks < num_processes) {
         refinementLevel++;
@@ -230,7 +232,7 @@ void BlockForest::initialize(int *argc, char ***argv) {
     math::AABB domain(xmin, ymin, zmin, xmax, ymax, zmax);
     int gridsize[3] = {32, 32, 32};
     auto procs = mpiManager->numProcesses();
-    auto block_config = use_load_balancing ? Vector3<uint_t>(1, 1, 1) : getBlockConfig(procs, gridsize[0], gridsize[1], gridsize[2]);
+    auto block_config = use_load_balancing ? Vector3<int>(1, 1, 1) : getBlockConfig(procs, gridsize[0], gridsize[1], gridsize[2]);
     auto ref_level = use_load_balancing ? getInitialRefinementLevel(procs) : 0;
 
     forest = blockforest::createBlockForest(
diff --git a/runtime/domain/block_forest.hpp b/runtime/domain/block_forest.hpp
index 7a447c10e8eb2d90aa1ff70b7cb631f132d31c7a..6facb7d9e4d7f1e2a72935a8bdab67e060c87771 100644
--- a/runtime/domain/block_forest.hpp
+++ b/runtime/domain/block_forest.hpp
@@ -13,10 +13,11 @@ class BlockForest : public DomainPartitioner {
 private:
     std::shared_ptr<BlockForest> forest;
     blockforest::InfoCollection info;
-    std::map<uint_t, std::vector<math::AABB>> neighborhood;
-    std::map<uint_t, std::vector<BlockID>> blocks_pushed;
+    std::map<int, std::vector<math::AABB>> neighborhood;
+    std::map<int, std::vector<BlockID>> blocks_pushed;
     std::vector<int> ranks;
     std::vector<int> naabbs;
+    std::vector<int> aabb_offsetss;
     std::vector<double> aabbs;
     real_t *subdom;
     int world_size, rank, nranks, total_aabbs;
@@ -44,8 +45,8 @@ public:
     void initializeWorkloadBalancer();
     void updateNeighborhood();
     void updateWeights(real_t *position, int nparticles);
-    Vector3<uint_t> getBlockConfig(uint_t num_processes, uint_t nx, uint_t ny, uint_t nz);
-    uint_t getInitialRefinementLevel(uint_t num_processes);
+    Vector3<int> getBlockConfig(int num_processes, int nx, int ny, int nz);
+    int getInitialRefinementLevel(int num_processes);
     void setBoundingBox();
     void rebalance();
 
diff --git a/src/pairs/sim/domain_partitioning.py b/src/pairs/sim/domain_partitioning.py
index a6173004d422d8f2d06bb84c125df5597821b440..dae2d28fc0a518741ecfd5797e240ed9877adabd 100644
--- a/src/pairs/sim/domain_partitioning.py
+++ b/src/pairs/sim/domain_partitioning.py
@@ -78,7 +78,7 @@ class BlockForest:
         self.aabb_capacity      = sim.add_var('aabb_capacity', Types.Int32)
         self.ranks              = sim.add_static_array('ranks', [self.nranks_capacity], Types.Int32)
         self.naabbs             = sim.add_static_array('naabbs', [self.nranks_capacity], Types.Int32)
-        self.offsets            = sim.add_static_array('rank_offsets', [self.nranks_capacity], Types.Int32)
+        self.aabb_offsets       = sim.add_static_array('aabb_offsets', [self.nranks_capacity], Types.Int32)
         self.aabbs              = sim.add_static_array('aabbs', [self.aabb_capacity, 6], Types.Real)
         self.subdom             = sim.add_static_array('subdom', [sim.ndims() * 2], Types.Real)
 
@@ -105,7 +105,7 @@ class BlockForest:
             Assign(self.sim, self.nranks_capacity, self.nranks + 10)
             self.ranks.realloc()
             self.naabbs.realloc()
-            self.offsets.realloc()
+            self.aabb_offsets.realloc()
 
         for _ in Filter(self.sim, self.aabb_capacity < self.naabbs):
             Assign(self.sim, self.aabb_capacity, self.naabbs + 20)
@@ -114,8 +114,7 @@ class BlockForest:
 
         Call_Void(self.sim, "pairs->copyRuntimeArray", ['ranks', self.ranks, self.nranks])
         Call_Void(self.sim, "pairs->copyRuntimeArray", ['naabbs', self.naabbs, self.nranks])
-        Call_Void(self.sim, "pairs->copyRuntimeArray", ['rank_offsets', self.rank_offsets, self.nranks])
-        Call_Void(self.sim, "pairs->copyRuntimeArray", ['pbc', self.pbc, self.naabbs * 3])
+        Call_Void(self.sim, "pairs->copyRuntimeArray", ['aabb_offsets', self.aabb_offsets, self.nranks])
         Call_Void(self.sim, "pairs->copyRuntimeArray", ['aabbs', self.aabbs, self.naabbs * 6])
         Call_Void(self.sim, "pairs->copyRuntimeArray", ['subdom', self.subdom, self.sim.ndims() * 2])
 
@@ -123,12 +122,12 @@ class BlockForest:
         # Particles with one of the following flags are ignored
         flags_to_exclude = (Flags.Infinite | Flags.Global)
 
-        for i in For(self.sim, 0, self.sim.nlocal):
-            particle_flags = self.sim.particle_flags
+        for r in For(self.sim, 0, self.nranks):
+            for i in For(self.sim, 0, self.sim.nlocal):
+                particle_flags = self.sim.particle_flags
 
-            for _ in Filter(self.sim, ScalarOp.cmp(particle_flags[i] & flags_to_exclude, 0)):
-                for r in For(self.sim, 0, self.nranks):
-                    for aabb_id in For(self.sim, self.offsets[r], self.offsets[r] + self.naabbs[r]):
+                for _ in Filter(self.sim, ScalarOp.cmp(particle_flags[i] & flags_to_exclude, 0)):
+                    for aabb_id in For(self.sim, self.aabb_offsets[r], self.aabb_offsets[r] + self.naabbs[r]):
                         full_cond = None
                         pbc_shifts = []