locals, tests, and some cleanup and docs