Changed code to (hopefully) work with the new API