add comments & fix bugs.