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.