Update API to version 3.1 from upstream.

- Fix conflicts.
- Keep and/or add SMC-specific changes and customizations.