Added debug variable to control printf and puts statements