refactoring: rename input/output buffer indexes to next_in/next_out