Fix two bad bugs in thread.c.