Added -d option

fixed minor issues