Yang: 1. add comments;    2. refactor codes;    3. add some tests.