It's possible to do everything right and still get hit due to a distracted (usually by cell phone) or drunk driver. I had 2 very close calls in the last 2 days.
Close call #1: I was at an intersection. I waited for a green light, then waited one second to see if anyone would 'blow through the red' before proceeding. Well just as I start through this lady in a BMW on her phone flies though and I had to slam my brakes so hard I dismounted from my bike. She ended up slamming her brakes also, probably not to avoid me, but the other cars now going through the intersection. The light was firmly red when she came to it, not yellow.
Close call #2. I was riding through a road near a park. City workers such as policemen and bus drivers often park on the shoulder of the road to sleep or relax during (I assume) breaks. I was riding through the road at top speed when a bus decides to back up without checking the road. This one was going to hit me for sure. I did not have time to stop and there was no way to swerve around something as large as a bus. I screamed STOP! as loud as I could and out of sheer luck the driver heard me and hit the brakes less then a foot before making contact.
These two have been my closest calls in 3 years of commuting, and almost one of going 'car free' and they both happened back to back in the last two days. In both cases I don't think there is anything I could have done differently. There is not much you can do about a driver that is not paying attention.