Rename the pthread id var to tid from pid

And make some trivial refinements to the comments.