Moving in some changes from the no_thread branch.