Adapted to latest API changes.