Added debug flag for logging information and debugging