Add multi-thread support