Fixed handling of encoding and decoding code-blocks