Made the seen_entities method more efficient.