This is where the trickiest part of the I/O implementation lives and it's starting to get a bit big.