Closes #652, reusing internal thread ids via a bit map