   //  begin,    end,   size
   // -----------------------
 #ifdef _ORIG_SHMEM_
-  
+
   int *approxS = (int*)&shmem  [     0];            //  0*DIM,  2*DIM,  2*DIM
   int *directS = (int*)&approxS[ 2*DIM];            //  2*DIM,  3*DIM,  1*DIM
   int *nodesS = (int*)&directS [   DIM];            //  3*DIM, 12*DIM,  9*DIM
   int *prefix = (int*)&nodesS  [9 *DIM];            // 12*DIM, 14*DIM,  2*DIM
   int *sh_body = &approxS[DIM];
-  
+
   int *prefix0 = &prefix[  0];
   int *prefix1 = &prefix[DIM];
-  
+
   const int NJMAX = DIM*2;
   int    *body_list = (int*   )&nodesS   [  DIM]; //  4*DIM,  6*DIM,  2*DIM
   float  *sh_mass   = (float* )&body_list[NJMAX]; //  6*DIM,  7*DIM,  1*DIM
   float3 *sh_pos    = (float3*)&sh_mass  [  DIM]; //  7*DIM, 10*DIM   3*DIM
-  
+
   int *approxM = approxS;
   int *directM = directS;
   int * nodesM =  nodesS;

  for (int d = 1; d < DIM; d <<= 1) {
    offset--;
    __syncthreads();
    
    int iflag = BTEST(tid < d);
    int ai = (((tid2 + 1) << offset) - 1) & iflag;
    int bi = (((tid2 + 2) << offset) - 1) & iflag;
    
    int t       = prefix[ai];
    if (tid < d) {
      prefix[ai]  = (prefix[bi] & iflag) + (t & BTEST(tid >= d));

          __syncthreads();

          //step 2:
          int nl = calc_prefix<DIM2>(nb, &body_list[n_direct], tid);   // inclusive scan to compute number of leaves to process
                                                                       // to make sure that there is enough shared memory for bodies
          nb = directM[prefix1[nl_pre + nl - 1]];                       // number of bodies stored in these leaves

          // step 3:
          for (int i = n_direct; i < n_direct + nb; i += DIM) {          //segmented fill of the body_list
