Pass `window` and `undefined` as local variables
Refactor plugin architecture completely