Added doc comments and did minor changes (mainly cleanup).