 //	float4write("../datadir/linedata.bin", BIGdataCount, h_lines);
 	floatwrite("../datadir/windings.bin", BIGnroflines, h_windingdata);
 
+
+
+	free(hostvfield[0][0]);
+	free(hostvfield[0]);
+	free(hostvfield);
+
 	free(h_windingdata);
+	cudaFreeArray(dataArray);
 
 	return 0;
 }

			divide<<<dataCount/(steps*blockSize),blockSize>>>(d_alpha, d_beta, d_alpha);//Not Scalable!!!

			//Copy winding numbers from from device to host
			int BIGindex = yindex*(BIGgridSize.x/gridSizeRK4.x)+xindex;
			checkCudaErrors(cudaMemcpy(&(h_windingdata[BIGindex*(dataCount/steps)]), d_alpha, (dataCount/steps)*sizeof(float), cudaMemcpyDeviceToHost));
	
			cudaFree(d_alpha);
			cudaFree(d_beta);
			cudaFree(d_radii);

	//Allocate host array for the winding numbers
	float* h_windingdata = (float*) malloc(BIGnroflines*sizeof(float));

	for (int yindex = 0; yindex < BIGgridSize.y; yindex += gridSizeRK4.y) {
		for (int xindex = 0; xindex < BIGgridSize.x; xindex += gridSizeRK4.x) {

			float4 startloc = BIGstartloc + xindex/BIGgridSize.x * BIGxvec + yindex/BIGgridSize.y * BIGyvec;
			float4 xvec = BIGxvec * (gridSizeRK4.x/BIGgridSize.x);
