template.php cleanup