Updated to use constructors and polyfills. Updated the example.