Added proper threading for HTTP API