refs #7. Changed some loops to list comprehensions. Added some comments.