Trim codes, especially if they've been long term issues, can damage 02 sensors and cats, so I hope you haven't been ignoring stuff for a real long time.
Check for air leaks first. Hoses are inexpensive to fix, just a little time consuming to find.
Yes, I think that trim codes might be why you failed emissions. Read jfoj's sig link. Search for jfoj and read the link he has on 'solving misfires'
In NJ--Tierney's in Montclair, Sept. 25, 7:30 p.m.
In NYC Sat, Sept. 30, 8 p.m. at Broadway Comedy Club! Sat, Oct. 8, 6 p.m. at Greenwich Village Comedy Club.
Comedy can be a great cheap date!
Mangofy your E46!