Code Clean up

got rid of unnecessary loops, edits some comments.