Apply a patch from Mahadevan R, with minor formatting changes, to