Simplify logic in UploadProgressFunctor
Fix a memory leak.

We need to collect connections objects from time to time if not memory
usage will grow infinitely.