Reimplemented debug output. Fixed handling of encodings. Introduced the encoding3 test. All tests work.