Cleaned up a little more and added some more comments.