Improved MosDecoder

- more flexible and extensible design
- requires less memory