Fixed a bug with debug messages not obey the debug flag.