After Mexico achieved independence in 1821, the Castle became the official residence of the head of state. A number of these, especially Emperor Maximilian I and his wife, embellished and expanded the castle as well as the forest area around it. The Hill was also the site of the Battle of Chapultepec in 1847, between Mexican and U.S. troops led by General Winfield Scott. A band of cadets was at the Castle when it was attacked, and near the end of the battle, six of them decided to jump to their deaths from the castle on the hill to the rocks below. These six are referred to as the "Niños Héroes" and are honored by a monument near where their bodies fell. The castle remained the official residence of Mexican presidents until 1940, when this function was moved to the Los Pinos residence, and the Castle was converted into a museum.