made threads reference-counted