This loop could use some comments for future reference.