Corrected global declaration error and cleaned up template files.