Avoid uploading same file twice, bug fixes