I noticed you mentioned the idle speed varies, have you checked the IACV as they can get gummed up and do not move correctly, it would explain the idle speed problem and if too much air is being let through the engine will stall.
Another one to check and clean is the throttle body.
Finally have you disconnected the MAF to see if the engine idles better as these also play up.