Debug flag added so that console.log is configurable