Fix the final problems.  Template test code now works.
Add a bunch of debugging code that is very useful in trying to catch templates errors.
This commit fixes the only memory error valgrind found.

I'd say that is a pretty good score.