added some comments, updated whitespace