Port to APIv2

Hi!

This branch is a more or less straight port to APIv2.