adds command-debug level; fixes bugs in previous codes