C++ fix: use strtok_r() for multi-threaded execution