Fix: error reporting and read/write byte calculations