Initial huge refactoring of r_io still work in progress