Fixes #986
rebased onto 98f0a8f576833fc7bbb3225c20fe4317eb787f95
Pull-Request has been merged by pbokoc
Fixes #986