Smarter table of contents generation