yeah I would refactor the whole thing. Its currently quite hard to wrap your head around whats happening.

Seeing the perf increase it might be worth investing some time to implement Set/Map throughout webpack though :0