Fix 2.7 compatibility issues