great speed-up in TOC related code