factored out template junk