Put leaf functions to the struct leaf, not namespace leaf.

This will make templatizing them and explicitly instantiating them in the .cc file much easier.