add extension mechanism, move toc to extensions, update docs, fix bugs