Access `Relations.names` only when name hashing is enabled

Check individual commits for details.

This PR fixes broken scripted tests. I'm sorry for the regression!