THE 2 THINGS which pop to mind for me is:

Teething - loose poos and discomfort for teeth

and

Worms - often up all night and discomfort and lots of poo
does he has irritation around his bottom at all?

might be worth looking at