Fix minor issues in threads.c