 
   int i, j, k, h, jc0, jc1, jtodo;
   long long key;
-  int cnt, ival, icat, lastival;
-  int ccnt, ctot, cnew, bestival, tmp;
-  float update, tmpx, clogc, impty, minimpty, lastimpty;
+  int ccnt, ctot, cnew, cnt, ival, icat, lastival, bestival, tmp;
+  float update, cacc, impty, minimpty, lastimpty, tmpx;
 
   for (i = threadIdx.y + blockDim.y * blockIdx.x; i < ntrees*nnodes*nsamps; i += blockDim.y * gridDim.x) {
     // Process a group with fixed itree, inode, and ifeat

        lastival = tmp;
        lastimpty = tmpx;
      }
      if (ival == lastival) lastimpty = -1e7f;            // Eliminate values which are not at value boundaries
      if (lastimpty < minimpty) {
        minimpty = lastimpty;
        bestival = lastival;

      minimpty = __shfl(minimpty, jtodo-1);               // Carefully copy the last active thread to all threads, needed outside this loop     
      bestival = __shfl(bestival, jtodo-1);
      ctot = __shfl(ctot, jtodo-1);                
      cacc = __shfl(cacc, jtodo-1);
      lastival = __shfl(ival, jtodo-1);             
      lastimpty = __shfl(impty, jtodo-1);
    }
    if (threadIdx.x == 0) {
      out[i] = bestival;                                  // Output the best split feature value
      outv[i] = minimpty - T::ffinal(cacc, (float)ctot);  // And the impurity gain
    }
  }
}
