apply PR #997 to v2.5.x branch