Improve check for running_kernel