Fix 'invalid thread id' issue #13 by making sure tid is a C long int.