Clean up file accesses; ensure output streams are closed; 2 'miscellaneous' changes