This PR fixes the issue. I'm looking forward to integrating this if Gail thinks there's nothing to be added to this commit.