Improve temp files management, using tempfiles