Fix bad indexing in the new kernel code