          RawPointer(isLeaf),
          RawPointer(leafSpheresStartIndex),
          RawPointer(leafNodeIndices),
-         activeSphereIndices, // Currently active data indices
+         nActiveSphereIndices, // Currently active data indices
          leafSphereIndices, // number of old data points that have been moved to leafs
          nNewLeafIndices,
          leafNodes, // number of leafs prior to checking for new ones.


    const uint2 partitioning = partitionings[id];
    const unsigned int leftEntry = (partitioning.x - nLeafIndices) * 2;
    const unsigned int leftBegin = newEntries[leftEntry];
    const unsigned int rightEntry = leftEntry + (partitioning.y - partitioning.x);
    const unsigned int rightBegin = newEntries[rightEntry];
    const unsigned int endEntry = rightEntry + (partitioning.y - partitioning.x);
    const unsigned int rightEnd = newEntries[endEntry];
    
    nextPartitionings[id] = make_uint4(leftBegin, rightBegin,
                                       rightBegin, rightEnd);
}



        spherePartitions.swap(nextSpherePartitions);
        rayPartitions.swap(nextRayPartitions);

        cout << "\n ** Before Leaf removal **\n" << ToString(true) << endl;

        // *** Remove leafs ***
        CreateLeafNodes();        

        cout << "\n ** After Leaf removal **\n" << ToString(true) << endl;
    }

    CHECK_FOR_CUDA_ERROR();
