Refactored kernel and promise code.