instead of freeing the resource in mkd_xhtmlpage and mkd_dumptree, the mkd_cleanup now has to be explicitly called.