Start refactoring kernel function to use classes