Fix #457

I think this fixes #457 but I want to make sure it definitely hasn't broken anything before merging.

Also, I'm not sure this is a general fix for the issue - it might just magically work in this case.