When you click on links to various merchants on this site and make a purchase, this can result in this site earning a commission. Affiliate programs and affiliations include, but are not limited to, the eBay Partner Network.
Since the problem is occurring mainly at idle and then disappears at higher rpms indicates there may be a vacuum leak allowing unmetered air to enter the engine and cause the lean condition. This affects the air/fuel mixture and could result in the random misfire code as well.
I would suggest looking around the engine bay for vacuum leaks; check for any loose/damaged hoses or vacuum lines, or any cracks in the intake tube past the MAF, anywhere there could be a loss of vacuum. You could also check for leaks by spraying some throttle cleaner near hoses and intake manifold and listening for a change in rpm.
At the back center of the intake is a rubber elbow for the PCV system. This elbow fails and causes a large vacuum leak as well as lean codes. I'd start there since the elbow is only like $7 at the parts stores.