1) Fix silly regression in template_functions preference that caused all functions to be added to the custom function preference.

2) Change function registration and deregistration to restore function bodies if the name conflict goes away.
Merge branch 'master' of https://github.com/cbhaley/calibre