Bugs fixed.
Sync with master branch.