Cleanup and optimization of http_get()