Refactored REM polyfill so it can be used as a component.