Refactor, bring retries to worker code