Adapted to the latest API changes.