Use unique_ptr in MapEntities.