 			divide<<<dataCount/(steps*blockSize),blockSize,0,windings2>>>
 				(d_beta, d_alpha, d_alpha);//Not Scalable!!!
 
-			//Insert out-of-bound-check here to remove erronous winding numbers
-
-			//Copying the windingdata line-by-line back to the host
-			int globaloffset = yindex*blockSizeRK4.y*BIGgridSize.x*blockSizeRK4.x+xindex*blockSizeRK4.x;
-
-			int hsize = gridSizeRK4.x*blockSizeRK4.x;
-			int vsize = gridSizeRK4.y*blockSizeRK4.y;
 		
-/*			for(int ylocal = 0; ylocal < vsize; ylocal++) {
-				checkCudaErrors(cudaMemcpy(&(h_windingdata[globaloffset+ylocal*BIGgridSize.x*blockSizeRK4.x]), &(d_alpha[ylocal*hsize]), hsize*sizeof(float), cudaMemcpyDeviceToHost));
-			}*/
 			checkCudaErrors(cudaMemcpy2DAsync(
 						&(h_windingdata[globaloffset]),
 						BIGgridSize.x*blockSizeRK4.x*sizeof(float),

	//Allocate space to store origin data
	float4 *d_origins, *h_origins;
	checkCudaErrors(cudaMalloc(&d_origins, dataCount/(2*blockSize)*sizeof(float4)));
	h_origins = (float4*) malloc((dataCount/steps) * sizeof(float4));

	//Allocating the array to store the length data, both for host and device
	float *d_lengths, *h_lengths;
	checkCudaErrors(cudaMalloc(&d_lengths, dataCount*sizeof(float)));
	status = cudaMallocHost((void**)&h_lengths, (dataCount/steps)*sizeof(float));
	if (status != cudaSuccess)
		printf("Error allocating pinned host memory.\n");

	//Allocating the array to store the radius data, both for host and device
	float *d_radii, *h_radii;
	checkCudaErrors(cudaMalloc(&d_radii, dataCount*sizeof(float)));
	h_radii = (float*) malloc((dataCount/steps)*sizeof(float));

	//Allocating arrays to store the alpha and beta data to compute winding numbers.
	float *d_alpha, *d_beta;


	cudaFreeHost(h_windingdata);
	cudaFreeArray(dataArray);
	cudaFreeHost(h_lengths);
	return 0;
}

