Move templating from kernel to its member function
Merge pull request #238 from roshanr95/templating

Modify templating