The National Convention finally deposed Robespierre and turned against the extremes of the Terror in what became known as the Thermidorian reaction, named for the month in the revolutionary calendar in which it occurred. A new constitution was adopted, creating a bicameral legislature and a five-member executive Directory. However, the ideologically moderate regime was buffeted by opponents on the left and right, and it was dependent on the support of the increasingly powerful military. Napoleon Bonaparte, an army general, took power in a coup in 1799, becoming "first consul" of the republic. He proclaimed himself emperor in 1804 and engaged in years of warfare with the European monarchies before his final defeat at the battle of Waterloo in 1815. Napoleon's legacy was long-lasting. He transformed France by introducing a uniform legal code and system of bureaucracy, and spread the core ideas of the Revolution across Europe through his military conquests.