Use defer as to cleanup the tmp files.
Use temp dir to simplify declaring tmp files.