kernel - Refactor the kernel message buffer code