Pthread fixes