We took in saint 9 mo old with fear agression - she was frightened of all people, children included. Barking, growling, backing into the corner... Now 3 mo later she is a social butterfly loving all people - pure saint.
We just did 3 things:
1) people around and inside our house were asked to ignore dog at all - not pat her, walk past her and even not looking at her. We even did not treated her as our other dogs are really happy to see any visitors, so she was sitting in the corner and learning, that people are great fun.
2) At the same time she was constantly told off for inapropriate beheivior like barking.
3) socialization, socialization and more socialization outside house - we took her to city, used public transport, went to shops... If savvy people asked to pat her, I let them to do watching her like a hawk, and she actually learned just in 2 days that people are not dangerous. On the second day I allowed even an old lady with a walking stick (our dog was really abused and beaten heavy as a pup by elderly lady) to pat her and she was ok! Praising, encouraging, and strict no for wrong beheivior did the job.
All will be ok in your case. 5 mo old is that difficult time when they all are getting a bit strange, just ask as much friends to come in as you can. He will quickly get the idea that more people mean more fun!