We've already seen the debug log. Show the relevant raw events in your script. Raw events trigger before raw 001, and your script is clearly triggering a few. Please list those so we have information to reproduce this bug.

Without being able to reproduce the bug, Khaled can't fix it. Without steps to reproduce the bug, nobody here can reproduce it. As you pointed out, it's dependent on your script, which you have yet to provide.