Fix 3.1 some bugs