andrewchambers patch from ori
Latest commit 5720f16 Nov 21, 2017