Enough component replacing. Time to look at electrical connections.
1) Unplug the ECM - it's on the side of the engine bay near the brake booster against the wheel guard (and above it). Look at all of the pins in the connector. If there's ANY sign of taint/oxidisation, grab some electrical contact cleaner and have at it.
2) Find the earth near the ECU and undo it. Clean it, some D40s had some paint left in the threads and it gave an intermittent contact.
3) Unplug the battery, clean both terminals. Disassemble the positive battery terminal connections, clean, reassemble (don't try pulling the fuses out, they aren't removable). After everything is back in place on the battery, spray both terminals with the battery terminal sealer.
4) Trace the battery negative lead to the engine block and remove and clean it, reassemble.
That's the primary stuff out of the way.
Repeat the exercise for the following: EGR connector, Boost sensor connector, Boost Control Solenoid (BCS) connector.
Also try this: next time you get "limp mode", pull over, keep the engine running and pop the bonnet. Look at the arm under the turbocharger actuator. The arm SHOULD move a little. If it doesn't move and you can clearly see the lock nut, get someone to give the throttle a tap - if the arm still doesn't move, it might be a dying BCS. Mine's just died, and my new Tillix valve arrived today. Out with the drill and welder tomorrow!
Also, with the engine stopped, grab a fresh piece of 3mm hose and attach one end to the turbocharger actuator. Suck on the other end - the arm underneath should move up. If it doesn't, it could be a damaged diaphragm in the actuator (I've got TWO spares now, both have seen a few miles) or the vanes in the turbo could be sticking. Unlikely to be the latter, very rarely the former. Much more common is a BCS intermittent or failed - mine's gone twice (hence the Tillix valve) in 270,000km.