Cleaned the legecy code in template.php