Better performance for Document
Improvements to Document and fixes to httplib