Make HdtDocument a native object.
Add ability to close the document.
Move code to lib folder.