Re-factor the code; add new function to create HTTP client; modified getdata to use client as an argument; remove obsolete code