Fix/document race conditions

After running some tests with the new race detector in go 1.1, I found a few places where race conditions are present.

This pull request fixes a few of them, and adds comments about some others whose proper fix I couldn't decide on.