your engine running like shite when the light on is most likely due to it running in limp mode
it sets the map sensor to 65kpa & engine coolant temp to -45c so it will overfuel for a start
so 507 points too high rpm at idle so you need Throttle position & map sensor readings at idle to start with imo
could be throttle body, pedal position sensor / wiring- could be anything
if you are having difficulty understanding this then find / pay someone to sort this for you