Minor refactoring of binary IO.