Fixing parsing of tcp protocol stream.
Merge https://github.com/tcoram/maunder