Fixes n+1 queries on template repository