Merge changes I33d138ed,I0b7e9597 into main

* changes:
  Have ByteBuffer.wrap() use the appropriate subarray
  Move APF memory clear into its own function