Added more comments, minor formatting.