Merge some changes from appchan.