Refactor to respect the new API.