Contributed by Bharat Viswanadham. (cherry picked from commit 5b7ba48cedb0d70ca154771fec48e5c4129cf29a)