Refactored for updated API.