 In spite of subsequent reverses, Maximilian retained these gains at the Peace of Westphalia in 1648.During the later years of this war Bavaria, especially the northern part, suffered severely.In 1632 the Swedes invaded, and when Maximilian violated the treaty of Ulm in 1647, the French and the Swedes ravaged the land.