Hi Kev
I agree with Stu, my Z3 (2.0 litre 6 cylinder) did the same when the Cam Sensor went faulty.
You could change it to see if it makes a difference but I believe you will have two of them fitted, one for the inlet and one for the exhaust camshafts.
Other considerations could be the Vanos units playing up, seals gone and poor oil quality?
Check also if the fuel filter has been changed as if not then this can affect running as could the ignition coil so worth checking the plugs for condition and gaps
If the water pump has been replaced then there may some air trapped in the system, from memory there are some sneakily hidden bleed screws in the cooling system so worth measuring for cool/hot spots in the cooling system with an infrared temperature gun and bleeding the system if necessary