Improved pthread stuff.