Refactored ckernel_builder into a template