                       owners.begin(), partitionLeafs);
     // std::cout << "index moved to:\n" << owners << std::endl;
 
+    // TODO change to device_vector.swap, but that crashes right now
     std::swap(currentIndices, nextIndices);
+    //currentIndices.swap(nextIndices);
 
     // std::cout << ToString() << std::endl;
 }

    PartitionLeftRight partitionLeftRight(nextIndices);
    thrust::for_each(input, input + CurrentSize(), partitionLeftRight);

    std::swap(currentIndices, nextIndices);
}


__constant__ unsigned int d_leafIndexOffset;


                                thrust::device_vector<unsigned int>& leftIndices,
                                thrust::device_vector<unsigned int>& rightIndices) {

    // std::cout << "--SphereContainer::Partition--:" << std::endl;

    const unsigned int nextSize = rightIndices[rightIndices.size()-1];
    nextIndices.resize(nextSize);

