Updated to latest API and polyfills