Code documentation

Started documenting code, and rewording some existing documentation.