Refactor functions in kernel.c

It is unnecessary to assign variables.