Introduce more generic IO interface
Use the new IO interface in main
Add a custom field to the io structure