He built a number of castles to defend his borders, most thought to have been built between 1220 and 1230. These were the first sophisticated stone castles in Wales; his castles at Criccieth, Deganwy, Dolbadarn, Dolwyddelan and Castell y Bere are among the best examples. Llywelyn also appears to have fostered the development of quasi-urban settlements in Gwynedd to act as centres of trade. Hostilities broke out with William Marshal, 2nd Earl of Pembroke, in 1220. Llywelyn destroyed the castles of Narberth and Wiston, burnt the town of Haverfordwest and threatened Pembroke Castle, but agreed to abandon the attack on payment of £100. In early 1223, Llywelyn crossed the border into Shropshire and captured Kinnerley and Whittington castles. The Marshalls took advantage of Llywelyn's involvement here to land near St David's in April with an army raised in Ireland and recaptured Cardigan and Carmarthen without opposition. The Marshalls' campaign was supported by a royal army which took possession of Montgomery. Llywelyn came to an agreement with the king at Montgomery in October that year. Llywelyn's allies in south Wales were given back lands taken from them by the Marshalls and Llywelyn himself gave up his conquests in Shropshire. In 1228, Llywelyn was engaged in a campaign against Hubert de Burgh, who was Justiciar of England and Ireland and one of the most powerful men in the kingdom. Hubert had been given the lordship and castle of Montgomery by the king and was encroaching on Llywelyn's lands nearby. The king raised an army to help Hubert, who began to build another castle in the commote of Ceri. However, in October the royal army was obliged to retreat and Henry agreed to destroy the half-built castle in exchange for the payment of £2,000 by Llywelyn. Llywelyn raised the money by demanding the same sum as the ransom of William de Braose, Lord of Abergavenny, whom he had captured in the fighting. Marital problems 1230 Following his capture, William de Braose decided to ally himself to Llywelyn, and a marriage was arranged between his daughter Isabella and Llywelyn's heir, Dafydd ap Llywelyn. At Easter 1230, William visited Llywelyn's court. During this visit he was found in Llywelyn's chamber together with Llywelyn's wife Joan. On 2 May, de Braose was hanged; Joan was placed under house arrest for a year. The Brut y Tywysogion chronicler commented: "that year William de Breos the Younger, lord