Fix deprecation warnings and errors