Contributed by Bharat Viswanadham. (cherry picked from commit 3c1fe073d2fef76676660144e7dce2050761ae64)