Quite a few of your son's issues could be a sensitivity to salicylates, a naturally occurring chemical in food (fruits are highest, you can see a list here http://www.salicylatesensitivity.com/food-guide
). With my son, that caused lots of belly scratching, poor sleep, red cheeks.
To test this, remove ALL things on the food guide that are not on the low sals list for a week - you should start to see improvement if that is one of his issues. If it is, supplementing magnesium, molybdenum, and B6 will help build his tolerance - and reducing the amount of sals he consumes will probably be necessary long term.
The other thing I'd look at for undigested foods and tummy issues is low zinc. The classic test around here is to eat beets - and then watch for pink pee/poop. But undigested food generally means low stomach acid, and the most likely cause of that is low zinc.
So I'd start by trying to add some nutrients via supps, minerals (trace minerals + magnesium), and some B vitamins. At a bare minimum, zinc and mag - your list of symptoms matches very strongly with both zinc and magnesium deficiency. And I'd try a low sals diet for a week. And see where that gets you.
I'll also say that he'd be a very unusual kid if he has serious digestive issues and dairy and gluten aren't a problem for him. My son is autistic, and a year ago, started showing lots of digestive problems. I couldn't trace any particular reactions to casein or gluten, but we removed them both on an elimination diet. When we trialed them, they were both clear problems - GI issues initially, then behavioral (they made his autistic symptoms worse). After 8 months of gut healing and addressing nutrient deficiencies, we have successfully reintroduced both, so it's not necessarily a long term thing, but I'd definitely consider at least a 4 week trial diary and gluten free - not necessarily as your first step, but worth doing unless adding vitamins and minerals magically fixes everything! Failure to thrive is a big red flag for gluten intolerance, for example...
Oh, and one other thing you might consider is a hair test to look for metals toxicity. My son was toxic in antimony from his bed mattress and PJs - it's not just mercury that can cause issues for our more fragile kids.