woman from a noble clan, but instead married into the royal family: Queen Daemok was his half-sister, whose mother came from the Hwangju Hwangbo family, while his second wife, Lady Gyeonghwa, was born by his elder half-brother Hyejong, the second king of Goryeo, and his first wife Queen Uihwa of the Jinju Im clan. Along with studying Taizong of Tang's book Difan () to better understand what to do, as he found many similarities between his situation and that of Taizong, Gwangjong rewarded all those who contributed to the progress of Goryeo, also making much effort to maintain good diplomatic relations with neighboring countries. This allowed him to concentrate power from within and without the court, and, seven years after the start of his reign, enact a series of reforms to promote a stable and royal-centered political system, and to expand economy and military. His first reform was the law of emancipation of slaves () in 956. The noble families had many slaves, mainly prisoners of war, who served as private soldiers; they numbered more than commoners and didn't pay taxes to the crown, but to the clan they worked for. By emancipating them, Gwangjong turned them into commoners, weakening the noble families' power, and gaining people who paid taxes to the king and could become part of his army. This reform won his government the support of the people, while nobles were against it; even queen Daemok tried to stop the king as the law affected her family, but to no avail. Regarding foreign policy, Gwangjong maintained the close connection between China and Goryeo which was made by Taejo of Goryeo, focusing on the relationship with Later Zhou and the Song dynasty. Many diplomats were sent back and forth between the two countries, as well as many goods. Gwangjong also built diplomatic relationships with Wuyue. In 957, Later Zhou diplomat and scholar Shuang Ji was sent to Goryeo as an envoy. Gwangjong discovered his ability and requested him to stay; Shuang Ji agreed and worked as a Goryeo official: with his advice, Gwangjong instituted the national civil service examination () in 958, with the goal to expel officials who gained court positions due to family influence or reputation rather than by merit. The examination, based on the Tang's civil service exam and the Confucian classics, was open to all male free-borns to give everyone, not only the rich and