Prior to Galeazzo II Visconti's ascension to power, Milan was ruled by Giovanni Visconti, who brought Galeazzo II and Bernabò back from exile. Giovanni's military activities drew the ire of the Papacy during the late 1340s, which led to the Papacy writing a letter of complaint to Galeazzo II for the Visconti family's incursions in Faenza. Galeazzo II encountered more conflicts with the Papacy during his rule as signore due to his own policy of expanding Visconti influence with his brother Bernabò in North Italy. When the Visconti tried to re-establish their influence in Bologna, a conflict between the Visconti family and the Papacy occurred and this led to the excommunication of Bernabò for heresy. Furthermore, persuaded by the Papacy, Charles IV revoked the vicariate that he granted to the Visconti family in 1361, although he returned the title to them four years later on the condition that they remained loyal and obedient to the Holy Roman Empire and its emperor. Another war broke out in 1372 when Galeazzo II tried to retake the city of Asti, which was opposed by the Count of Savoy. Visconti military activity in the 1370s led to another conflict with the Papacy when Pope Gregory XI condemned both Bernabò and Galeazzo II Visconti as heretics as well as the revoke of their title as imperial vicar by the Holy Roman Emperor once more in 1372.