I'd be looking in the following order
1, coil packs and/or power transistor
2, spark plugs
3, afm
4, cas
I've had all of the above problems on every nissan i've owned - to me it sounds more like a coil pack and/or power transistor than an afm problem (but just in case, check for filter remnants or gunk on the afm and give it a good electrical contact clean for safe measure.
If it's the cas, your timing will change frequently, check with a timing light. Or if you're inclined take the cas out and check for wear on the spindle.