Adapted code to öatest changes in API (checkout latest snapshot).