WIP: Begin to add a RetryFailed option.
Also, refactoring the overlarge runOne function.