with building the first monastery building named Samye around late 8th century. According to some legend, it is noted that he pacified the Bon demons and made them the core protectors of Dharma. Modern historians also argue that Trisong Detsen and his followers adopted Buddhism as an act of international diplomacy, especially with the major power of those times such as China, India, and states in Central Asia that had strong Buddhist influence in their culture. Yeshe Tsogyal, the most important female in the Nyingma Vajrayana lineage, was a member of Trisong Detsen's court and became Padmasambhava's student before gaining enlightenment. Trisong Detsen also invited the Chan master Moheyan to transmit the Dharma at Samye Monastery. Some sources state that a debate ensued between Moheyan and the Indian master Kamalaśīla, without consensus on the victor, and some scholars consider the event to be fictitious. Era of fragmentation (9th–10th centuries) A reversal in Buddhist influence began under King Langdarma (r. 836–842), and his death was followed by the so-called Era of Fragmentation, a period of disunity during the 9th and 10th centuries. During this era, the political centralization of the earlier Tibetan Empire collapsed and civil wars ensued. In spite of this loss of state power and patronage however, Buddhism survived and thrived in Tibet. According to Geoffrey Samuel this was because "Tantric (Vajrayana) Buddhism came to provide the principal set of techniques by which Tibetans dealt with the dangerous powers of the spirit world... Buddhism, in the form of Vajrayana ritual, provided a critical set of techniques for dealing with everyday life. Tibetans came to see these techniques as vital for their survival and prosperity in this life." This includes dealing with the local gods and spirits (sadak and shipdak), which became a specialty of some Tibetan Buddhist lamas and lay ngagpas (mantrikas, mantra specialists). Second dissemination (10th–12th centuries) The late 10th and 11th centuries saw a revival of Buddhism in Tibet with the founding of "New Translation" (Sarma) lineages as well as the appearance of "hidden treasures" (terma) literature which reshaped the Nyingma tradition. In 1042, the Bengali master Atiśa (982-1054) arrived in Tibet at the invitation of a west Tibetan king. His chief disciple, Dromton founded the Kadam school of Tibetan Buddhism, one of the first Sarma schools.. Atiśa, helped in the translation of major Buddhist texts such as Bka'-'gyur (Translation of the Buddha Word) and Bstan-'gyur (Translation