Backport thread handle backwards-compatibility fix

This backports #254.