Cherry picked from dev-branch.