some improvements added to support dynamic template files per source file