should probably use ByteBuffer.wrap(bytes, offset, length) here too, to avoid wrapping the extra bytes?