Fixed upstream with PR #431, but applied locally until next upstream merge