Cleanup of kernel.cpp