Sync up with C++ version