Added comments and did some cleanup