Yet more refactoring of the API