Fix race conditions in pool.go.

I finally got to my workstation. I've consolidated all the fixes into one CL, and fixed compile errors and tests.