Added DEBUG flag and a DEBUG function for the monitor