2004 Subaru Forester - Won't re-start after being driven

Hello,

I have a 2004 Subaru Forester with 90k miles on it. Its been great for the Boston Winters, but this summer its started an unusual problem. After driving the car until it is warmed up, it won't start again. When l turn the key, the car shakes as the starter engages, but the car will not turn over unless I try a few times. Once its running, it runs without any issues. If I leave the car for a few hours (shorter if its cold or the hood is up, longer if its hot out), it turns on without issue.

The latest time, I turned the car on after having problems getting it started, and the engine temp light was flashing. I turned it off, checked the coolant level, it was fine. The engine temp gauge reads normal, and the car started back up again (with some difficulty) but ran without problem. This light has only done this twice.

Some possibly useful info: Its a 2004 subaru, 90k miles, non aspirated. Its had a blown head gasket reparied by the dealer a year and a half ago. Most recently, I had a new starter put in when my mechanic noticed a problem with the car starting.

The problem started a month ago, and I immediately brought it to a mechanic who could not replicate the problem. A CEL came on at the time, but it was most likely due to a cheap gas cap from Auto Zone. I promptly replaced it with a OEM, and the CEL has not come back on since. A few days ago, my mechanic replaced the crank shaft sensor hoping to fix the problem. It didn't.

Any suggestions?

Thanks