Properly free all XML documents.
Minor style fixes.
Fix dt_tag_exists implementation.

Remove quote around ?1 to avoid SQLite3 error.
Do not return name, not needed.
Set tagid to -1 as described in the spec.