I've tried to pull out as much as seemed practical, without ending up with too many method arguments.  So each clause I reduced to three method calls.  I could move the state=RESET call and the retried_XXmax increment down into _submit_for_retry, but that would mean two increments.  Would it be clearer to do that?