Added some comments and did some cleanup.