updates for consistency in I/O and cleaning up files