Reference fixes

many many example fixes, plus some template formatting tweaks (to make examples with CDATA characters both compile right and look right)