Add the document fragment node type

Also do some cleanup and fix some bugs