 Complete the following phrase:  In July 1239, he was assigned as Imperial vicar general in Lombardy, as well as General-Legate in Romagna, and left Sardinia never to return. Sharing in his fathers excommunication in the same year, he took a prominent part in the war which broke out between the emperor and the pope. In 1241, he took part in the capture of a papal fleet at the Battle of Giglio in the Tyrrhenian Sea. His first successful move as military leader was the reconquest of Jesi, in the Marche, which was Fredericks birthplace. In May 1241 he was in command of the forces which defeated the Genoese fleet at Meloria, where he seized a large amount of booty and captured a number of ecclesiastics who were proceeding to a council summoned by Gregory to Rome. Later he was captured in a skirmish against the Milanese at Gorgonzola, but soon released. In 1245 or 1246 his marriage was annulled. In 1247, he took part in the unsuccessful 