Fix kernel
Small refactor
Minor fixes