Thread has been converted to a C++ object. Still not perfect but it is
definitely better than it was before.