Additional attempt at fixing TOC nesting with mixed-up sections.

Added some debugging messages.
Merge branch 'nested_toc' into version