     newClusterSize = (int*) calloc(numClusters, sizeof(int));
     assert(newClusterSize != NULL);
 
-    malloc2D(newClusters, numClusters, numCoords, float);
+    malloc2D(newClusters, numCoords, numClusters, float);
+    memset(newClusters[0], 0, numCoords * numClusters * sizeof(float));
 
     //  To support reduction, numThreadsPerClusterBlock *must* be a power of
     //  two, and it *must* be no larger than the number of bits that will

    } while (delta > threshold && loop++ < 500);

    *loop_iterations = loop + 1;

    checkCuda(cudaFree(deviceObjects));
    checkCuda(cudaFree(deviceClusters));


    free(dimObjects[0]);
    free(dimObjects);
    free(dimClusters[0]);
    free(dimClusters);
    free(newClusters[0]);
    free(newClusters);
    free(newClusterSize);
