Fixed bugs in upload recovery  logic