refactoring regarding entity_ptr and ent management #6