If this is a TD5 I'd have a look at the injector wiring loom. This is a common issue that can give these symptoms. The seal from the camcover can leak and this sends oil down into the red plug on your ECU, which can cause all sorts of running problems. Check the red plug for oil. If its there...