 
 	float imMin = 0;
 	threads = dim3(NUMTHREADS,1,1);
-	grid = dim3( (imageSize-1)/NUMTHREADS+1, 1, 1);
+	grid = GetGrid(imageSize);
 	kern_PopulateWorkingDown<T><<<grid,threads,0,*stream>>>(GPUWorkingBuffer, agreement, GPUInputBuffer, requiredAgreement, imageSize);
 	for(int t = (imageSize-1)/2+1; t > 0; t/=2){
 		threads = dim3(NUMTHREADS,1,1);

void CUDA_ILLT_AllocateHistogram(float** histogramGPU, int size, cudaStream_t* stream){
	cudaMalloc((void**) histogramGPU, sizeof(float)*size);
	dim3 threads(NUMTHREADS,1,1);
	dim3 grid( (size-1)/NUMTHREADS + 1, 1, 1);
	
	#ifdef DEBUG_VTKCUDA_ILLT
		cudaThreadSynchronize();

	#endif

	dim3 threads(NUMTHREADS,1,1);
	dim3 grid = GetGrid(size);
	IncrementBuffer<T><<<grid,threads,0,*stream>>>(GPUBuffer, desiredValue, agreement, size);
	cudaFree(GPUBuffer);

