Merge "Reduce ifs lock scope." into sc-dev