Refactor retrying/connection pooling