JMS #17: Made improvements to template rendering code