First attempt at new API. Lots of TODOs and CHECKs.