Refactor toc_generator; remove two unnecessary lines