Several bugfixes and improvements.
Input and output binary streams.