Neo, from your description you have either a 200 or 300TDi, that being the case the P38 referance is confusing as from my understanding a P38 is a V8.
Okay, assuming you have either the 200 or 300TDi then your box is a ZF4HP22, if you do have a P38 V8 then it should be a ZF4HP24, in either case there shouldnt be any electronics, if the box is playing up with gear changed 90% of the faults can be resolved by a service of the govenor, chances are its clogged with goo from the auto-box clutches.
Its not a job for the faint hearted though, apart from the hassle of removing it from the vehicle the internals are fairly complicated, I did my original box before I saw the light and imported an Ashcroft stage 2 one. The Ashcroft Stage 2 is a ZF4HP22 but with the ZF4HP24 oil pump, (bigger and more robust) bevel gears clutches upsized torque converter etc. and well worth the expence.
If you decide to DIY get a service manual first, a super clean work area to dismantle and re-assemble the box is essential and patience. ZF do a complete service kit (valve springs, gaskets, seals and bearings) and I got mine from the USA on Ebay - when / if ordering one you MUST quote the serial and model number of your box as the govenor is not interchangeable, with that of, for example a V8 or 5 cylinder engine as its centrifugal springs and valves are designed to suit the torque and rev range of the particular engine it was designed for.engine