Heavy refactoring of all file I/O and some memory handling; also repaired some inconsistencies via the resulting standardizations.