Handle partial reads and unify header reading (sonar)