I have had very similiar problems for the past few years. I found a cure that works for me 100% of the time. I believe my lower stomach flap leaks stomach acid while I sleep - resulting in exsesive break down of solids in my intenstines -resulting in gas the next day. I changed my eating patterns drastically to correct this. I eat a filling breakfast and lunch, then I eat nothing for the remainder of the day. I have not expiremented with eating time frames as this new diet has changed my life, but even eating the smallest amount of anything late in the day - such as a handfull of chips or sunflower seeds gets the acid flowing in my stomach - allowing acid to leak out at night. I can drink anything I want after lunch as this seems not to affect it.
they say not to eat 4hrs before going to sleep, but this time frame was too short for me. Hope I helped:)