updates from @cjolif and @sbrunot