Minor fixes.
Make retry count thread safety.