Refactor io.c into two modules