TemplateForensics: reorganized some code. No functional change intended