Refactored Kernel.php