#341 Fix TemplateFactory cache synchronization