bugfixes and new debug subcommand