Fixed general issues
Fixed template.php