1994 Corolla - Intermittent Starting Problem

My 1994 Corolla has a very weird, intermittent starting problem. It first appeared last summer and the car would crank, but not start up. This happened maybe once every other week. It would eventually start after cranking it a couple of times. As fall came around the problem went away and I forgot about it. Of course if reappeared again this year. This time it is way more frequent. Had a mechanic look at it. He replaced the distributor. Didn't help. I also replaced the fuel pump, filter, spark plugs, and ignition wires, following various people's advice. Hard starting issue still persists.
Here's what I found out: The car always starts in the morning. The issue seems to be appearing only when it has been sitting in the sun for a couple hours (i.e. it gets warm inside, but not too hot). Sometimes I can get it started by spraying starting fluid into the air intake. This worked 3 out of 4 times. After trying cranking a couple of times, waiting, then crank again, it will eventually start...
Checked error codes today and got an error code 12 (RPM signal).

The dilemma is that the problem is ONLY WHEN STARTING. Otherwise it runs perfect, has enough power, doesn't run rough or stall. My theory is that if there is a faulty part which is used to run the engine then I would have issues WHILE DRIVING as well, which is not the case.

Any ideas?
I would probably check the ignition system... Take one spark plug out, and keep it in the wire. Then disconnect all other spark plug wires. Hold the tip of the spark plug against the valve cover (to ground it), and have a friend crank the engine. You should get a nice healthy blue spark. If you don't until you've cranked it a while, my guess would be it's the timing sensor (a magnetic switch thingamajiger that counts the notches in the ring that sits behind the crank timing pulley. I don't know if it's adjustable or not, but you may be able to move it in or out...)

P.S. Wear gloves, as if you have an excellent ignition system you can easily get shocked.. And let me tell you, it hurts...