Improved creation of table of contents