Fix #831 actually by sbillard on the fork which I forgot to credit properly.
Merge remote-tracking branch 'upstream/master'