Fix for bug FLEX-33707: Re-work of patch file submitted by Pratyoosh Sharma.