Code cleanup, and docs.