misc fixes

Fixes for:

- deprecated API usage
- NPE when running the tool/gen_api.dart script
- added a TODO: for some unfortunate patterns in the json files