added some comments, cleanup