Moved array variables for template and output into the first foreach loop for the files so that it creates an empty array for each output file and doesn't add previously compiled templates into later template files.  This fixes issue #22