Added a switch for debug messages