Fixes and improvements to Document and HttpLib