Fixes to retry logic