3.1 deprecation fixes

Fix 3.1 deprecation notices, but also breaks compatibility with 3.0.