cleaned up, and added some more comments.