support input order in multi
missing header for Linux
reduced wasteful decoding by caching

The change is risky. It is surprising that it works at the first try. I thought
to spend some hours to debug...