Early Kuala Lumpur was a small town that suffered from many social and political problems – the buildings were made of wood and ''atap'' (palm frond thatching) that were prone to fire, lack of proper sanitation plagued the town with diseases, and it suffered from a constant threat of flooding. The town became embroiled in the Selangor Civil War due in part to the fight for control of revenues from the tin mines. The Chinese Kapitan Yap Ah Loy allied himself with Tengku Kudin, and the rival Chinese gang allied themselves with Raja Mahdi. Raja Asal and Sutan Puasa also switched sides to Raja Mahdi, and Kuala Lumpur was captured in 1872 and burnt to the ground. Yap escaped to Klang where he reassembled a fighting force. Kuala Lumpur was recaptured by Yap in March 1873 when Raja Mahdi forces were defeated with the help of fighters from Pahang. The war and other setbacks, such as a drop in tin prices, led to a slump. Furthermore, a major outbreak of cholera caused many to flee the town. The slump lasted until late 1879, when a rise in the price of tin allowed the town to recover. In late 1881, the town was severely flooded, following a fire that had destroyed the entire town in January that year. That the town was rebuilt a few times and thrived was due in large part to the tenacity and persistence of Yap Ah Loy. Yap, together with Frank Swettenham who was appointed the Resident in 1882, were the two most important figures of early Kuala Lumpur with Swettenham credited with its rapid growth and development and its transformation into a major urban centre.