I had a similar problem when I first bought my car. I had it tested for codes and nothing was showing up so, I asked around and found that the most common answer was "These motors are known for crank sensor problems."
So... I brought it in and had the sensor replaced. But, before it was replaced, the mechanics cleaned up the little bit of corrosion from under the box, found some exposed wires (they were all still in their insulation though) and taped them up. They checked the grounds and cleaned them up aswell. After all of that, they replaced the sensor (this was all done in the same day). I haven't had any problems with it since.