Rough Idle, p0126, p2402 Help!

2007 Mazda 3, 5 dr GT
Hi, I am new to the forum. Thanks in advance for any advice you may have!

I have a 2007 Mazda 3 2.3L 5 dr. It has recently started to idle roughly and occasionally comes close to stalling while in park. I scanned for codes and came up with P0126 (Thermostat?) and P2402 (EVAP Leak detection Pump?) Both are problems I need to address but could they be the cause of the rough idle or is it something else?
2008 Mazda 3i 4 dr Touring Value Edition
Yes, the codes can cause a poor idle. Get those problems corrected and your idle will probably improve.
The thermostat code indicates coolant thermostat is stuck open. That would affect engine warn up,
in cold weather it may never warm up. I would check the thermostat first. The code P0207 could be
caused by a vacuum in the hoses for the evaporative emission system.

2005 mazda 3 hatch
For the first code if you want to check your thermostat pull it out and put it in boiling water. If it doesn't open then you know its no good. If you have a vac leak try spraying your intake hoses with start fluid . If you rpms rev higher then you know you have a vac leak..
Stock or not? Po126 I just had it was thermostat. Then I had a vacuum leak and it was throwing po2187 and I had a bad bpv hose and vacuum hose T since I'm full recirc. Fixed and coded haven't returned.