Fix how stats key are generated for entities.