Added debug constants. Also replaced echo statements by calls to debug().