I just replaced the crankshaft position sensor. A pain of a job on the M272. Lots of conflicting information on the Internet on what bolt type it is. Since you can't see it and you need to undo it by feel this is important. For reference on my car it was a TX30 Torx.
At least first test drive check engine light is not on and the car drives well. We'll soon see if it has fixed the issue properly.