Fixes a problem when there is more than one 'templates' occurrence in path