Added dbgprintf a debug message printer than can be turned on and off by defining DEBUG