More toc fixup to produce valid HTML.
Move support scripts to 'lib' folder.