added code tightening, explanations, and/or typo corrections