Update for API changes

This should get pulled after #1 and is a rebase of that.