Better use of ByteBuffer