Yang: 1 add some comments; 2 refactor code.