Fixed implementation for new API changes.