More work on the API to make it more robust.