Further improvements and bugfixes to upload script