Prevented infinite loops when finding matches.