 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);
+	dim3 grid = GetGrid(size);
 	
 	#ifdef DEBUG_VTKCUDA_ILLT
 		cudaThreadSynchronize();


	float imMin = 0;
	threads = dim3(NUMTHREADS,1,1);
	grid = dim3( (imageSize-1)/NUMTHREADS+1, 1, 1);
	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_GetRelevantBuffers(short** agreement, int size, cudaStream_t* stream){
	cudaMalloc((void**) agreement, sizeof(short)*size);
	dim3 threads(NUMTHREADS,1,1);
	dim3 grid = GetGrid(size);
	ZeroOutBuffer<short><<<grid,threads,0,*stream>>>(*agreement,size);

	#ifdef DEBUG_VTKCUDA_ILLT
