Refactored to use Apache HTTP Client.