Well............
The ECM is getting no data at times or data that is not agreeing with what the Cam Sensor is telling it. What is the part number on the sensor you put in there? Sounds to me like you bought a generic cheapy and not the OEM sensor we always preach about...