These are two attempts to fix #931. @gmaxwell Can you test if either if the first commits solves the issue? (The third commit is just a minor cleanup thing that I discovered on the way).
If yes, I’d probably prefer the first commit, which is a real fix. But we could still apply the second commit if people think that’s a good idea.