Eliminate global variable %D

Global variable `%D` was used to keep a per-instance state (but also
prevented per-instance callbacks). Replacing XML::Twig callbacks with
subs calling instance methods allows using the object itself to store
this state info instead. Also eliminated obsolete "use vars" in favor of
"our" declaration (valid since 5.6.0, March 2000)