Refactored httpclient-based client.