1. Start slow.
2. Use herbs that aid digestion when cooking (cumin, ginger, for example).
3. Consider a good probiotic. My favorite is seed.com (no conflict of interest).
I have found it to be helpful to soak most beans for 24 hours, with a refresh of the water about halfway through. Then, cook most beans for several hours (lentils and mung are good go after one hour and can be soaked for just 7 hours or so). When they begin to boil, skim all of the foam off the top and then return to a simmer.￼ No hard science to back this up. Just traditional practices you might try if beans make you gassy or bloated.