issue #5932: add safe guard for unroot and fix args processing bugs