Reorganized the api.