Refactor.
Cache compiled template functions.