Various small fixes to I/O support