This fixes #797
rebased onto a4d2b23ec9517b423616a3c698297f9ad3fdcdee
Pull-Request has been merged by bcotton
This fixes #797