Matrix based encoder/decoder.

Added block encoder/decoder.
Block encoder/decoder operates on blocks.
Some micro optimizations have gone in.