Fixes #986
Fixes #1058