Count retained template content rather than only the default key; keep names-only inventories distinct. Fixes #6569