Added threadnum_t and used it everywhere you would want it used.