update codes from upstream
Merge pull request #1926 from minggo/master

Synchronize from upstream