Move capture_io into its own file