Some refactorings for shorter retry loops.