Fix a few issues.

Fixes #5011 and #5002 .
I think it is still used for entity names.