updated fix for fx-141

Simplified & optimized previous commit and made it over latest codebase,
1 test in message tests fails, need to figure out why. I've tried but not yet quite understood the whole code...
Perf test is close to original version. One time it is better, the other - worse. Please retest on you env.
BTW, decoding/encoding is not the hotspot - see picture.
![image](https://f.cloud.github.com/assets/3398019/1631452/307cfed0-5765-11e3-86a2-dc5900ea635c.png)