Add a mutex to protect the events map.

Fixes 7 races that the race detector was complaining about right off the bat.
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.
Merge pull request #1 from anachronistic/races

Races
Refactored Connection.stopped

* Added getter and setter
* Wrapped both getting and setter in mutex Lock/Unlock
removing defer
Merge pull request #2 from jpoz/stoppedRefactor

Refactored Connection.stopped