Following the Russo-Turkish War (1877–1878), the empire granted independence to all three belligerent nations. Bulgaria also achieved virtual independence (as the Principality of Bulgaria); its volunteers had participated in the Russo-Turkish War on the side of the rebelling nations. The government's series of constitutional reforms led to a fairly modern conscripted army, banking system reforms, the decriminalization of homosexuality, the replacement of religious law with secular law and guilds with modern factories. 1839–1861 Abdülmecit I 1840s The Ottoman Ministry of Post was established in Istanbul on 23 October 1840. The first post office was the Postahane-i Amire near the courtyard of the Yeni Mosque. The introduction of the first Ottoman paper banknotes (1840) and opening of the first post offices (1840); the reorganization of the finance system according to the French model (1840); the reorganization of the Civil and Criminal Code according to the French model (1840); the establishment of the Meclis-i Maarif-i Umumiye (1841) which was the prototype of the First Ottoman Parliament (1876); the reorganisation of the army and a regular method of recruiting, levying the army and fixing the duration of military service (1843–44); the adoption of an Ottoman national anthem and Ottoman national flag (1844); the institution of a Council of Public Instruction (1845) and the Ministry of Education (Mekatib-i Umumiye Nezareti, 1847, which later became the Maarif Nezareti, 1857); the abolition of slavery and slave trade (1847); the establishment of the first modern universities (darülfünun, 1848), academies (1848) and teacher schools (darülmuallimin, 1848). Samuel Morse received his first ever patent for the telegraph in 1847, at the old Beylerbeyi Palace (the present Beylerbeyi Palace was built in 1861–1865 on the same location) in Istanbul, which was issued by Sultan Abdülmecid who personally tested the new invention. Following this successful test, installation works of the first telegraph line (Istanbul-Adrianople–Şumnu) began on 9 August 1847. Identity Card and Ottoman Census, 1844 While the Ottoman Empire had population records prior to the 1830s, it was only in 1831 that the Office of Population Registers fund (Ceride-i Nüfus Nezareti) was founded. The Office decentralized in 1839 to draw more accurate data. Registrars, inspectors, and population officials were appointed to the provinces and smaller administrative districts. They recorded births and deaths periodically and compared lists indicating the population in each district. These records were not a total count of the population. Rather, they were based on what is known as