Added debug mode as an option