Updated to handle the latest API changes.