Few fixes for Darwin: workaround over different readlink -f and sed -i behaviors