Refactor with new API changes.