Move some kernel functions to global