Initial implementation from Kernel.