Compartmentalized addEntity() function.