Migrate codes from the 2.5 branch