Fix publication

Tested both commits. The first fixes the publication problem we have now in production in case of direct stageout. The second fixes an issue about retry counts and maximum retries when having resubmissions.