Added support for command retries (previous patch incorrectly applied)