Updated code to make use of debug option.