Refactored to use async HTTP API.