Merge "Fix race condition in checkPattern and verifyPattern." into cw-f-dev