add comments, remove some unused code