add some comments and remove unused code