Hello and welcome to justanswer.com
You should start by having the battery tested as this may be due to low voltage. For the code P1587 that is usually a fault with the throttle control module located under the throttle. It comes as an assembly. If this is a V6 engine inspect the engine harness as sometimes it will short out on the bracket in the back of the intake manifold.