Improvements and fixes provided by Rob Tweed.

Many related to access of sub-elements, that take advantage of the fact
that the setDocument() method instantiates all the nodes of the hierarchy.

Thanks Rob.