bit of refactoring and some bugfixes related to stray bytes in case of unrecognized commands (also when a command is valid, but no device is active to handle it)