He said he's replaced the AFM. So unless its is another dodgy AFM and/or dodgy wiring then that isn't his problem. I have this problem with my R32 GTS-T atm and have had an ECU diagnostic tool plugged into it and the CAS reading goes crazy when it loses all power. My ECU also had an AFM fault so i cleared it and went for a drive and it came back. I'm going to change the CAS asap and will prob change to a Z32 AFM soon. You've said you have checked and replaced both of these though, there's a thread still going atm with a problem a bit like your and he changed the fuel pressure regulator and it fixed his problem so you could try that maybe. Let us know how you go mate!
Cheers
Stricko