Split/refactor io module