Fix for #544

Hopefully this isn't one of those too-good-to-be-true fixes, but it looked pretty straightforward to me.