   }
 
   __syncthreads();
-  for(particleID = 0; particleID < PARTICLE_PER_BLOCK; particleID++) {
-    dotP = DotProductGPU(gpu_kx[threadID], gpu_ky[threadID], gpu_kz[threadID],
+  for(int particleID = 0; particleID < PARTICLE_PER_BLOCK; particleID++) {
+    double dot = DotProductGPU(gpu_kx[threadID], gpu_ky[threadID], gpu_kz[threadID],
       shared_coords[particleID * 3], shared_coords[particleID * 3 + 1],
       shared_coords[particleID * 3 + 2]);
     double dotsin, dotcos;


  if(threadID >= imageSize)
    return;
  int i;
  double dotP;

  // TODO SET SUM ARRAYS TO ZERO
  if(blockIdx.y == 0) {

  double *gpu_particleCharge;
  double * gpu_energyRecip;
  double * gpu_final_energyRecip;
  int atomNumber = coords.Count();

  CUMALLOC((void**) &gpu_particleCharge,
