Fixed leaking temporary files, and a race condition when uploading many small files.