Keep track of the filename for each token and fix the error output
regarding template filenames.