Fix bug with checking _pid from gate instead of _pid+1 and add minimal mfence