Speed optimization and code re-organization

This PR improve by a factor 10 the upload time by using a better file tracking approach.

DO NOT REVIEW