More IO utils, bug fixes