Improve I/O support and various other fixes

Mostly refactoring I/O support into IOFile and ReadManager, stronger
FORMAT support and validation, source code fixes and tests.