Refactor some of the IO stuff into its own namespace