Changed the way in which temporary files are generated