STYLE: clean original code and add more comments.