Refactored connection retry behaviour.
Merge pull request #14 from cbracken/retry-cleanup

Refactored connection retry behaviour.