add comments and do some cleanup