Fixes to template doc mode