Improved storage of template files in temp directory