Bug fixes to IO