Fix bug #1017