OK, that sounds good for point 2. (I edited my comment to make the 2 points clearer.)

For point 1, I think you could do this:
````scala
val buffer = ChannelBuffers.dynamicBuffer(min(frame.getBinaryData.readableBytes() * 2, bufferLimit))
````