delete unnecessary lines and add comment in important places