Fixes #1030
Fixes #1031
Merge pull request #1034 from emmanuel-keller/master

Bug fixes