New APIs and lots of fixes