Apply fix #517

Fixes #517