There’s someone else who had the exact same error, and they solved it by replacing the PIEInstanceID != INDEX_NONE statement to:
if(PIEInstanceID == INDEX_NONE) {
PIEInstanceID = 1;
};
Like they said in the thread, it’s a temporary solution, but it seems that creating an empty map solves the problem as well. Not sure if that solution would work for you, but it’s worth giving the if statement a try.