TYRUS-239: Improving ByteBuffer handling.

- significant performance gain
- works correctly for all cases (previous impl contained a bug..)