remove race conditions
A bunch of race condition fixes from running the tests with go test -race
. And enable that flag in the CI by default: #223 (closed)
I believe one of the race conditions that is fixed in the email support was the cause of #129 (closed)
I have also clean up some staticcheck errors in the code.