Fix an error seen when building documentation
Fix two use-after-free bugs.
Fix significant memory leak.

Particularly, unserializing a function is frequent and leaked.
Fix broken links in the documentation

Also removed a duplicate link under "Script Reference".
Fix various potential memory leaks.

Though I expect most not to be exercised in practice.
Merge branch 'fastpath'
Merge branch 'topic/dnthayer/doc-fix-links'

BIT-1076 #merged