Merge from Perforce
Fix the bugs found in 2.5 branch and migrate them to 2.1 branch