Engine races and transmission labors when cold



I recently had the head gasket replaced and the water pump on my 2000 Dodge Dakota A/T 6 cyl. engine. It has 100,000 miles on it. The engine races when I start it in the mornings and after it has sat for a couple of hours. When this happens, the transmission labors in 1st gear like it can’t shift into 2nd. Does anyone have any suggestions?