Added debug switch and configuration