Work on documentation, and some code cleanup