Optimize the kernel code