     thrust::transform_inclusive_scan(leafNodeValues, leafNodeValues + nActiveNodes, 
                                      leafSpheresStartIndex.begin()+1, MarkLeafSize(), 
                                      thrust::plus<unsigned int>());
-    cout << "leafSpheresStartIndex:\n" << leafSpheresStartIndex << endl;
+    cout << "leafSpheresBeginEntries:\n" << leafSpheresStartIndex << endl;
     const size_t nNewLeafIndices = leafSpheresStartIndex[leafSpheresStartIndex.size() - 1];
     cout << "nNewLeafIndices: " << nNewLeafIndices << endl;
 

         nNewLeafs, // number of new leafs
         // results
         RawPointer(nextSphereIndices),
         RawPointer(nextSphereIndexPartition));
    CHECK_FOR_CUDA_ERROR();

    // Copy new leaf geometry indices back into the old array to maintain a
    // complete list of leafs indices in both arrays (TODO only copy to the main

        blocksize = funcAttr.maxThreadsPerBlock > 256 ? 256 : funcAttr.maxThreadsPerBlock;
        blocks = (activeNodes / blocksize) + 1;
        
        CreateNextPartitionings<<<blocks, blocksize>>>
            (RawPointer(spherePartitions) + leafNodes,
             RawPointer(sphereLeftRightEntries),
             RawPointer(nextSpherePartitions) + leafNodes,
             leafSphereIndices, activeNodes);
        CHECK_FOR_CUDA_ERROR();
        // cout << "nextSpherePartitions:\n" << nextSpherePartitions << endl;

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