API changes

Do not merge yet, it's work in progress towards a nicer v2 API.