Clean up template semantic process

Standardize three phases - findTemplateDeclaration, semanticTiargs, and findBestMatch