                                                                               scale,
                                                                               threshold);
         }
-        uint32_t index_count_clamped = min(index_capacity, index_pyramid[8].x);
+        uint32_t index_count_clamped = min(index_capacity, index_pyramid[4].x);
         if(index_count_clamped) {
           extractIndices<<<(index_count_clamped + 255) / 256, 256>>>(index_output,
                                                                      vertex_pyramid,

                                     const uint32_t input_index)
  {
    uint32_t key = input_index;
    // Traverse apex
    uint32_t offset = 0;
    offset = processHP5Item(key, 0, pyramid[9]);
    offset = processHP5Item(key, 5 * offset, pyramid[10 + offset]);
    offset = processHP5Item(key, 5 * offset, pyramid[15 + offset]);
    for (unsigned l = level_count - 4; 0 < l; l--) {
      offset = processHP5Item(key, 5 * offset, pyramid[level_offset[l] + offset]);
    }

                                                    ctx->level_sizes[i - 1]);                    // Number of sideband elements from level i-1
        sb = !sb;
      }
      reduceApex << <1, 4 * 32, 0, stream >> > (ctx->index_pyramid + 4,
                                                ctx->sum_d,
                                                ctx->index_sidebands[sb ? 0 : 1],
                                                ctx->level_sizes[ctx->levels - 4]);
      // FIXME: Try to combine these two kernels into one, as they are independent.
      reduceApex << <1, 4 * 32, 0, ctx->indexStream >> > (ctx->vertex_pyramid + 4,
                                                ctx->sum_d + 1,
                                                ctx->vertex_sidebands[sb ? 0 : 1],
                                                ctx->level_sizes[ctx->levels - 4]);
