My near misses have been because some idiot decides to hug or even drive in the cycling lane (usually while texting) or when someone parks a car in the cycling lane forcing me to move into the road (with cars being incapable of waiting for me to get around the idiot that decided to park in the cycling lane).
Those are instances of following the road rules perfectly yet still nearly getting in a dangerous wreck.
It's not a problem of rules, it's a problem of cyclists not having safe places to cycle. It's a problem of cities not planning for cyclists. It's a problem of cities not enforcing rules that ultimately protect cycling.