More robust handling for when to autogenerate a TOC and when not to.