Closes #571.

Thank to Stitchous.