 SphereContainer::SphereContainer(HyperCubes& cubes, SpheresGeometry& spheres,
                                  uint* spherePartitionStart)
     : spheres(spheres),
-      indices1(thrust::device_vector<unsigned int>(spheres.Size()*cubes.Size())),
-      indices2(thrust::device_vector<unsigned int>(0)),
-      doneIndices(thrust::device_vector<unsigned int>(0)),
+      indices1(spheres.Size()*cubes.Size()),
+      indices2(spheres.Size()*cubes.Size()),
       currentIndices(indices1), 
-      nextIndices(indices2) {
-    
+      nextIndices(indices2),
+      doneIndices(spheres.Size()*cubes.Size()) {
+    
+    nextIndices.resize(0);
+    doneIndices.resize(0);
+
     thrust::device_vector<Cone> cones(cubes.Size());
     thrust::transform(cubes.Begin(), cubes.End(), cones.begin(), createCones);
     //std::cout << cones << std::endl;

                                     thrust::device_vector<unsigned int>& owners) {

    /*
    std::cout << "--PartitionLeafs--:" << std::endl;
    std::cout << "isLeaf:\n" << isLeaf << std::endl;
    std::cout << "leafNodeIndices:\n" << leafNodeIndices << std::endl;
    std::cout << "spherePartitions:\n" << spherePartitions << std::endl;

                      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;
}
