apply @MattiJarvinen patch from issue #75