First refactor with byteio streams