kernel: clean and refactor

Signed-off-by: Domenico Marino <johnlemon.lol@gmail.com>