Added debug switch (-d)