Fix cleanup when listing branches