     sphereIndices.resize(spheres.Size() * cubes.Size());
     sphereIndexPartition.resize(sphereIndices.size());
     
-    thrust::device_vector<Cone> cones(cubes.Size()); // TODO can't this be parsed in from outside to save allocation and dealloc?
+    thrust::device_vector<Cone> cones(cubes.Size()); // TODO can't this be passed in from outside to save allocation and dealloc?
     thrust::transform(cubes.Begin(), cubes.End(), cones.begin(), CreateCones());
 
     unsigned int spherePartitionPivots[cubes.Size() + 1];

    
    // Geometry partition
    
    doneSpherePartitions = 0;
    while (spherePartitions.size() - doneSpherePartitions > 0) {
        // Create new ray partitions through binary search
        nextRayPartitions.resize(rayPartitions.size() * 2);

        thrust::transform(hyperCubes.Begin(), hyperCubes.End(), cones.begin(), CreateCones());
        std::cout << "cones:\n" << cones << std::endl;

        // Assign geometry to each childs cone and compute new indices for geometry moved left and right.
        static thrust::device_vector<uint2> sphereLeftRightIndices(sphereIndices.size());
        sphereLeftRightIndices[0] = make_uint2(0, 0);
        sphereLeftRightIndices.resize(sphereIndices.size() - doneSphereIndices + 1); // +1 for dummy element
        thrust::transform(sphereIndices.begin() + doneSphereIndices, sphereIndices.end() + doneSphereIndices,
                          sphereIndexPartition.begin() + doneSphereIndices, 
                          sphereLeftRightIndices.begin() + 1,
                          SpherePartitioningByCones(cones, spheres.spheres));
        std::cout << "sphereLeftRightIndices:\n" << sphereLeftRightIndices << std::endl;

        thrust::inclusive_scan(sphereLeftRightIndices.begin() + 1, sphereLeftRightIndices.end(),
                               sphereLeftRightIndices.begin() + 1);

        cudaFuncGetAttributes(&funcAttr, AddFinalLeftIndexToRightIndices);
        blocksize = funcAttr.maxThreadsPerBlock > 256 ? 256 : funcAttr.maxThreadsPerBlock;
        blocks = (sphereLeftRightIndices.size() / blocksize) + 1;
        AddFinalLeftIndexToRightIndices<<<blocks, blocksize>>>(RawPointer(sphereLeftRightIndices),
                                                              RawPointer(sphereLeftRightIndices) + sphereLeftRightIndices.size()-1);
        std::cout << "sphereLeftRightIndices:\n" << sphereLeftRightIndices << std::endl;



        rayPartitions.swap(nextRayPartitions);

        // Remove leafs


        exit(0);
    }
