Add httpfetch debug (todo: remove this)
Clean up httpfetch code a bit and fix potential memory leaks