Partially added the handling of the -d option.