Fixes #1882 and #1902

Signed-off-by: Carlos Escribano <carlos@doofinder.com>