I would need to see more code to figure out how to reduce it. There is a lot of redundancy so I'm thinking it can be. But as Klippy said, if its called somewhere like plugin_init or plugin_cfg, this is done at map change only and will not affect gameplay. Reducing code for the sake of reducing it might not be a reasonable reason to re-write half of this plugin.