Fixing retry logic, whitespace cleanup

This brings in some fixes related to retry logic and connection cleanup