My car was purchased with the check engine light on due to a bad EGR valve. At the time, this was the only code that was showing because I drove it to autozone and cleared the codes, then went through two run cycles to see if any more popped up. Anyway, I have since replaced the EGR valve, but when I tried to erase the codes, 4 new codes showed up.

These are the codes:
P0410 - Secondary air injection system
P0412 - Secondary air injection solenoid relay control circuit bank 1
P0418 - Secondary air injection pump relay control circuit bank 1
P0300 - Engine misfire detected- random cylinders

I was wondering if anyone knew the cause of these codes or what could be causing the misfire. I bought some new spark plugs that I'm planning to install whenever the weather is good. Also I heard the top 3 codes could be cleared by removing the EGR/Air injection and pump system but I would like to keep the car as stock as possible. I thought the cause of all of them could be something related to the EGR valve because I read that air leaks can cause a misfire.

The engine runs a little rough and has cut off before at idle on two or three occasions which I'm assuming is due to the misfire.
Any help is appreciated, I'm really just trying to find out which parts I need to replace to fix this problem for good.