Adding thread support