Fixes #172, submitted by jns