added @cemeyer's libcurl improvement to @luac's optimizations
I have no idea what I'm doing at this point but it seems right