Bug fixes to stream handling and commands.