Make PooledConnection execute only a finite number of time
Fixing some lint errors
Various logic fixes and style clean up.
Move retry count increment so that max_retries actually means retries and not attempts.