P01864 means battery disconnected within last 50 starts. If this occurred occasionally, or just after disconnecting the battery, then the code is not pointing at any fault. Just telling you that the battery has been disconnected. The code will be erased after cranking 50 times.
If the problem comes back times and times again even if you have not disconnected battery in last 50 starts check crank sensor and battery wiring.
Check also oil pump sensor, cam and MAP sensor. If car starts in second gear I will also have a loot to connectors at PCM and TCM and to wiring to throttle position sensor and vehicle speed sensor.
Usually the code is displayed if the battery has been disconnected withing the last 50 starts. In that case there is no fault and the problem with second gear is not related. About the car starting in wrong gear test the solenoids in the valve body, the TPS, the wiring to TCM and the VSS. Here some troubleshooting about similar shifting problems.