           n_bodies     -= nb;                                   //subtract from n_bodies number of bodies that have been extracted
           nl_pre       += nl;                                   //increase the number of leaves that where processed
           direct [tid] -= nb;                                   //subtract the number of extracted bodies in this pass
-#if 0
           prefix0[tid] = max(prefix0[tid] - nb, 0);             //same here, but do not let the number be negative (GT200 bug!?)
-#else
-          offset1 = max(offset1 - nb, 0);
-          prefix0[tid] = offset1;
-#endif
           n_direct     += nb;                                  //increase the number of bodies to be procssed
 
           while(n_direct >= DIM) 

        if (flag && nodes[offset + 6] == 0) nodes[offset + 6] = child + 6;
        if (flag && nodes[offset + 7] == 0) nodes[offset + 7] = child + 7;
        __syncthreads();
#endif

        n_offset += n_total;    //Increase the offset in the array by the number of newly added nodes


        body_list[tid] = direct[tid];                                            //copy list of bodies from previous pass to body_list
        sh_body  [tid] = jbody;                                                  //store the leafs first body id into shared memory


        // step 1
        offset = inclusive_scan_block<DIM2>(prefix_shmem, (int)flag, tid);       // inclusive scan on flags to construct array
        if (flag) prefix1[offset - 1] = tid;                                     //with tid's whose leaves have to be opened
        __syncthreads();                                                         //thread barrier, make sure all warps completed the job
       
        // step2 
        offset2 = inclusive_scan_blockS<DIM2>(prefix_shmem, nbody, tid);        // inclusive scan to compute memory offset for each body
        int offset1  = offset2.x;
        int n_bodies = offset2.y;                                               //Total number of bides extract from the leaves
        __syncthreads();                                                        // thread barrier to make sure that warps completed their jobs

        direct [tid]  = offset1;                                            //Store a copy of inclusive scan in direct
        offset1      -= nbody;                                              //convert inclusive int oexclusive scan
        offset1      += 1;                                                  //add unity, since later prefix0[tid] == 0 used to check barrier
        prefix0[tid] = offset1;
        __syncthreads();

        int nl_pre = 0;                                                     //Number of leaves that have already been processed

