Clean up how local-mode i/o is done. Add docs & tests.