cleanup of ByteBuffer code and more testing