Fix deprecation warnings and sync with latest API