Gas pains

Does anyone else get such bad pains in the sides of their stomachs under their ribs that literally is soooooooo painful you just can't help but curl up in a ball and scream? Went to the ER and they told me it's just gas which can be severely painful in pregnant women. Anyone deal with this? I'm almost 16 weeks and I've had it twice. First time lasted an hour and a half. Second time lasted for an hour. What have you done to relieve this kind of pain? And how do you prevent it?