support limiting number of retries, plus some bug fixes, typo corrections