Adding a missing line of code that i forgot to add! The missing line was causing a nasty bug:
the list of already uploaded files was not filled up in memory but only on disk.