Added debug-ability for template.php. Added logfile for templates. Can be disabled.