added some comments, removed unused code