Added debug message and logfile capabilities