Added toggledebug command, changed error handling