Fix some more race conditions

Another `-race` load testing.
I'm not very sure about changes to `server/buildfile.go`, but it seems working good.
ping @vieux @unclejack @crosbymichael