Cleans code to complete the pull request from peili, which was committed with a513d6d.