Cleanup to mirror the cleanup in chan-pthreads

Also changed all the modifications to the blockedWriters and blockedReaders counters to use atomic operations with barriers.