Replace WeakMap with Map + polyfill