Added debug mode, call with -d parameter