Classic icv and tps. That's idle control valve and throttle position sensor.
Anyway.....longshot but in case the tps does not solve the problem.....disconnect the engine coolant temperature sensor. That can cause really weird engine symptoms too. The sensor is under the intake manifold for m50 engines and is tough to get to...do this when the car is cold. There are two sensors, only one goes to the dme (that's ecu) and the other goes to the dashboard temp gauge. You want to get the first one. Its no biggie if you get the second one as well but find some way to avoid mixing them both up if you disconnect both and you need to reconnect one.
If you disconnect the ect sensor and your problem goes away, then you've got the culprit. Drive with it off until you can get a new one fixed in. Your fuel economy will suffer somewhat in the interim period. IN fact, forgot, that's another clue that your ect is busted. Along with your current symptoms, your fuel economy should be tanking. If you're also getting repeated o2 sensor codes, (suggesting that repeated overfuelling is taking place) then you've got yet another symptom.
So please clean the tps, that's the easiest thing to do and my money's on that, and if the problem does not go away, then disconnect the ect and see.
Please update your thread with your findings later. Thank you.