pre-cherry-pick some parts of b044e0a to simplify future mergings -- it introduces g_debugEntities, but without any logic attached to it