Improve handling of epubs with TableOfContents.

TableOfContents epubs are a tricky situation, as each TOCReference can have
multiple children, and so for each child.

Also various tweaks and bugfixes