Add mutexes to protect the Connection and Event structs.

Eliminates the remaining races that the race detector was complaining about in the test suite. This just kind of silences specific noise for now though.