'97 Jeep XJ, RPM problems

I have a 1997 Jeep Cherokee Sport that I had bought roughly 1 year ago. It has 186000 miles on it. At one point I had stalling problems and I fixed it by replacing the crankshaft position sensor. Everything was fine months after, however I have found a new problem has risen.

About once a week, under any weather condition or air temperature, my RPMs would shoot up and down for around 10 seconds, while a sound is heard, it seems on the left side of my engine, past and under where the steering wheel is. This sound can only be described as a hollow tin-can sound if you were to shake possibly a hard bean in the can. A hollow rattling sound. This only happens for around 5 - 10 seconds, then it goes away and doesn’t come back for another week or so.

Another thing that happened is once at a gas station I turned on my car, and my car idled very high, around 1500-2000 RPMs, until I started driving for about 20 seconds, the RPMS went back to normal. ANOTHER thing that happened is my car seemed to have low power and my RPMs went lower than normal, until I heard a “popping” sound and everything turned back to normal. It didn’t sound healthy.

I have no clue what this could be, and I am nervous that it could be my transmission going out. Could that be it? Or is it something loose that I just have to tighten?