Modify templating

Move templating from kernel to its member function. Probably should have been there in the first place...