Added exception handling for setup_io()