tpl code cleanup