Fix error handling for wrong kernels