Re-rolling #54 patch against 8.9.x branch.