fix to main_template.php after updates from Andrew