Make HTTP requests in a separate thread. Refactored the thread code to another file.