Also improve the state handling in the different IO manager implementations with a RAII state handler