Fixed memory alloc/dealloc for doctype and document objects.