Fixed compiler errors when enabling memory debugging.
Added an assertion when creating an invalid node in debug mode.
Fixed a memory issue caused by not referencing the owner node when setting a document's root.