strdup replaced because it is not standard.