     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;
 

        blocksize = funcAttr.maxThreadsPerBlock > 256 ? 256 : funcAttr.maxThreadsPerBlock;
        blocks = (activeNodes / blocksize) + 1;
        
        cout << "CreateNextPartitionings<<<" << blocks << ", " << blocksize << ">>>" << endl;
        cout << "spherePartitions:\n" << spherePartitions << endl;
        cout << "sphereLeftRightEntries:\n" << sphereLeftRightEntries << endl;
        cout << "nLeafSphereIndices: " << leafSphereIndices << endl;
        cout << "nActiveNodes: " << activeNodes << endl;
        cout << "nLeafNodes: " << leafNodes << endl;
        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);

        bounds.resize(nextActiveNodes);
        thrust::transform(nextRayPartitions.begin() + leafNodes, nextRayPartitions.end(), 
                          bounds.begin(), CreateBoundsFromPartitions(rayMortonCodes));
        // std::cout << "bounds:\n" << bounds << std::endl;

        static HyperCubes hyperCubes(128); hyperCubes.Resize(bounds.size());
        thrust::transform(bounds.begin(), bounds.end(), 
