Contributed by Bharat Viswanadham. (cherry picked from commit d7b012e5600fa19b330d61a2572499f14fe9bb61)