More warnings for everybody.
Fixed leaks.
Simple optimization: return original template if no substitutions made.
Added some internal autorelease pools.