Correct the result, fix some bugs.
Merged.