and amended Welsh law as followed in Gwynedd. Llywelyn's amendment to Welsh law favouring legitimate children in a Church-sanctioned marriage mirrored the earlier efforts of the Lord Rhys, Prince of Deheubarth, in designating Gruffydd ap Rhys II as his heir over those of his illegitimate eldest son, Maelgwn ap Rhys. In both cases, favouring legitimate children born in a Church sanctioned marriage would facilitate better relations between their sons and the wider Anglo-Norman polity and Catholic Church by removing any "stigma" of illegitimacy. Dafydd's older but illegitimate brother, Gruffydd, was therefore excluded as the primary heir of Llywelyn, though would be given lands to rule. This was a departure from Welsh custom, which held that the eldest son was his father's heir regardless of his parents' marital status. In 1220, Llywelyn induced the minority government of King Henry to acknowledge Dafydd as his heir. In 1222, he petitioned Pope Honorius III to have Dafydd's succession confirmed. The original petition has not been preserved but the Pope's reply refers to the "detestable custom... in his land whereby the son of the handmaiden was equally heir with the son of the free woman and illegitimate sons obtained an inheritance as if they were legitimate". The Pope welcomed the fact that Llywelyn was abolishing this custom. In 1226, Llywelyn persuaded the Pope to declare his wife Joan, Dafydd's mother, to be a legitimate daughter of King John, again in order to strengthen Dafydd's position, and in 1229, the English crown accepted Dafydd's homage for the lands he would inherit from his father. In 1238, Llywelyn held a council at Strata Florida Abbey where the other Welsh princes swore fealty to Dafydd. Llywelyn's original intention had been that they should do homage to Dafydd, but the king wrote to the other rulers forbidding them to do homage. Additionally, Prince Llywelyn arranged for his son Dafydd to marry Isabella de Braose, eldest daughter of William de Braose. As William de Braose had no male heir, Llywelyn strategized that the vast de Braose holdings in south Wales would pass to the heir of Dafydd with Isabella. Gruffydd was given an appanage in Meirionnydd and Ardudwy but his rule was said to be oppressive, and in 1221 Llywelyn stripped him of these territories. In 1228, Llywelyn imprisoned him, and he was not released until 1234. On his release, he was given part of Llŷn to rule. His