add comments and first round of "tree pruning"
code cleanup (comments, formatting, etc.)