[Refactoring] template.c

A little clean up around template instantiation code.