Definitely check that crank sensor and the crank wheel. I was just catching up with BMWMan91's crank damper failure thread. It's a relatively rare occurrence but I've heard about it more than once.
The 1241 error indicates the AFM has a problem. Potentially the idle air valve could also be at fault. Have you ever replaced (or deleted

) the rat's nest of vac & coolant lines under the intake manifold? Any air leaks there will cause running problems.
I'd guess the rebuilt unit is OK, is the harness connector damaged or wet? I'd test the AFM out too. Next time the car misbehaves, disconnect the AFM and see if the car's idle improves. It won't be able to rev, of course, but if the AFM had problems the car's idle should change once the harness is unplugged.
I'm just brainstorming, but you've already eliminated all the other common E30 culprits, right? Ignition switch is OK? Fuses are good, not too loose in the fuse box terminals? No melting fuse box? Start wire is securely connected everywhere? You've disabled any original anti-theft systems?
I don't think the M42 cars have a DME code box. IIRC they didn't, but it's a common problem on other classic Bimmers.