         // Read data back into registers
         if (!MEMOIZE)
         {
-            #pragma unroll
-            for (int i = 0; i < SEGMENT_LENGTH; i++)
-            {
-                cached_segment[i] = smem_raking_ptr[i];
-            }
+            CopySegment(cached_segment, smem_raking_ptr, Int2Type<0>());
         }
 
         ThreadScanExclusive(cached_segment, cached_segment, scan_op, raking_partial, apply_prefix);
 
         // Write data back to smem
         CopySegment(smem_raking_ptr, cached_segment, Int2Type<0>());
-/*
-        #pragma unroll
-        for (int i = 0; i < SEGMENT_LENGTH; i++)
-        {
-            smem_raking_ptr[i] = cached_segment[i];
-        }
-*/
     }
 
 

        // Read data back into registers
        if (!MEMOIZE)
        {
            #pragma unroll
            for (int i = 0; i < SEGMENT_LENGTH; i++)
            {
                cached_segment[i] = smem_raking_ptr[i];
            }
        }

        ThreadScanInclusive(cached_segment, cached_segment, scan_op, raking_partial, apply_prefix);

        // Write data back to smem
        CopySegment(smem_raking_ptr, cached_segment, Int2Type<0>());
/*
        #pragma unroll
        for (int i = 0; i < SEGMENT_LENGTH; i++)
        {
            smem_raking_ptr[i] = cached_segment[i];
        }
*/
    }




        // Read data into registers
        CopySegment(cached_segment, smem_raking_ptr, Int2Type<0>());

        T raking_partial = cached_segment[0];

        return GuardedReduce(cached_segment, scan_op, raking_partial, Int2Type<1>());
