Fix #1017

This PR should close #1017.