Fixes CONTRIB-4938 and CONTRIB-4871

Signed-off-by: Joseph Rézeau <moodle@rezeau.org>