I think he kept barking at your friend because he wanted more treats. For the other incidents of him barking and lunging, I got the impression that he had not been probably socialized by his previous owner. So, I suggest you start with working on the barking. There are many threads on that and some suggest teaching first the speak command, and then the quiet command. The book, "Barking: the Sound of a language" by Turid Rugaas has helpful ideas.
Sting Chance von Gaard AKC GSD 2/8/2006