Contributed by Varada Hemeswari. Cherry-picked from commit ref 3de574413c4d5554213d02bd0ad343ba82cf82aa